Hey everyone,
I have code (R of course) that I have running on my PC. Every hour my PC wakes up and runs my .bat file which runs my .R script.
I don't like the idea of my computer continuously waking up. Some times I come home and my task scheduler ran the code past my end time (lets say 4pm EST).
What I would like is to host my .R script somewhere on the cloud and have that run every hour between 9am-5pm. I was advised to check out github.com/jhuckaby/Cronicle to complete this task. I am curious to know what you guys do to run your scripts continuously.
Thanks for your help.
1) get a droplet on for example digital ocean or aws for 5$ a month.
2) you must be able to run c++ on your droplet:
Run C++ on linux: https://rupinderjeetkaur.wordpress.com/2014/06/20/run-a-cc-program-on-terminal-using-gcc-compiler/
3a: configure your cronjob
https://crontab-generator.org/
3b: create a cronjob
https://docs.oracle.com/cd/E19253-01/817-0403/sysrescron-72169/index.html
But why would you need C++, you should be able to run R code directly via cron.
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.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.
View attachment 217447
We are almost there. So I followed the links instructions and pushed a script to git.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
Not sure what you mean but i'll try to guess.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
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-vpsNot 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.
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.
Yes, when you use : "git clone <repository>" you have the working code files on your VPS that you can now execute.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