Where to host your code to run systematically

Discussion in 'App Development' started by TheBigShort, Jan 22, 2020.

  1. carrer

    carrer

    I used to have a python script to scan stock price. Web scraping.
    I then converted the code to PHP and run it on a free hosting site. No cost.

    If you can convert your R code to PHP then it's free.
     
    #11     Jan 22, 2020
  2. Best thing for you is pay for a windows VM (I am partial to Azure) and use the scheduler as you're doing now.

    Forget about nickel and diming. Optimize costs after you've optimized trading.
     
    #12     Jan 22, 2020
  3. ^ This is the answer by a mile.
     
    #13     Jan 22, 2020
    Stamamarti likes this.
  4. TheBigShort

    TheBigShort

    I decided to go the route of Digital Ocean with Ubuntu. Everything is up and running and I have R installed on my VPS.

    My next step is going to be using cron to run my R script. However I am not too sure how to save an R script to re-use in the console. I am so used to using R Studio that I am not to sure how this works.

    My working directory is /root

    I want to print "hello world" from my script myfile.R all day everyday. I create a statement
    * * * * * /root/myfile.R>> ~/cron.log 2>&1 (or something like that). What I am confused about is how do I create the myfile.R that simply has a print("helloworld")? In Rstudio I would simply press save. Then, if I want to use the script again I would read the file back in.

    Screen Shot 2020-01-23 at 3.48.28 AM.png
     
    #14     Jan 23, 2020
  5. Heydrrich

    Heydrrich

    Setup a git repository. It will sync your files on your local machine with the files on the VPS. That way you can test/program the code on your local machine and when you are satisfied, you push the files to the VPS, where it can be executed.


    Here is how to set it up.
    https://www.digitalocean.com/community/tutorials/how-to-install-git-on-ubuntu-18-04
     
    #15     Jan 23, 2020
  6. TheBigShort

    TheBigShort

    We are almost there. So I followed the links instructions and pushed a script to git.
    The script simply says - every 5min send me an email with the time of day.

    I would like to run the file and turn off my computer to see it in action. Is this line the final piece to the puzzle?

    wget -O - https://raw.githubusercontent.com/<username>/<project>/<branch>/<path>/<file>| sudo bash
     
    #16     Jan 24, 2020
  7. Heydrrich

    Heydrrich

    Not sure what you mean but i'll try to guess.

    You need to have a script that is able to send a mail to your address. That is the only thing that it should do. You can program this on your own computer until it works. Once it works you should be able to run that script as a command.

    Now you want to have that script on your VPS, so you push your local working code to your Git repository.

    Once you pull the code (from your repository) via Git on your VPS, you should be able to setup a cronjob (on your VPS) that runs that file via a command every 5 minutes, because that is what cronjobs do; running commands at a specified interval.
     
    #17     Jan 24, 2020
  8. TheBigShort

    TheBigShort

    Brilliant. Thanks for all your help @Heydrich. To add to your advice, this link was the final piece for me https://www.digitalocean.com/commun...t-up-automatic-deployment-with-git-with-a-vps
     
    #18     Jan 24, 2020
  9. TheBigShort

    TheBigShort

    Actually one more thing Heydrrich. I am going to be pulling from my github. When I pull, do I have to clone the whole document or is there an alternative
     
    #19     Jan 24, 2020
  10. Heydrrich

    Heydrrich

    Yes, when you use : "git clone <repository>" you have the working code files on your VPS that you can now execute.

    https://www.katacoda.com/courses/git this website looks to be a good resource on how to work with Git.
     
    #20     Jan 24, 2020
    mercurial likes this.