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.
Do you mean like a $5/month hosted server? https://aws.amazon.com/lightsail/pricing/ https://techcrunch.com/2016/11/30/aws-announces-virtual-private-servers-starting-at-5-a-month/
hey guru I think you are familiar with C++ IIRC. I need a program that will run the C++ script every N hours. Lets say you have a simple script Code: #include <iostream> using namespace std; int main() { cout << "Hello, World!"; return 0; } I want my instance on AWS to run this at specific time intervals. I am not to sure how to do it.
I have some of my C# program(s) running 24/7 in a loop and they just wait for specific time and execute various functions. Otherwise cron on Linux, or if you're using Windows then maybe Windows task scheduler? https://stackoverflow.com/questions/132971/what-is-the-windows-version-of-cron
AWS also seems to support scheduling tasks: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/scheduled_tasks.html
I am currently doing windows task scheduler which is what I am trying to move away from. It looks like I want to go the approach you took with your C# script. Would you mind giving me a brief overview and then I'll fill in the gaps. I am more interested on how you set up the server and how much it's costing you.
So in my case it's just a console app in C# that loops and waits for various time points. Here is a screenshot: I also record each event's start/end time in a database, and later can review logs. I run/host this on my own server at home, so not paying anything externally. I do have additional, colocated servers at a web hosting company, but I had to bring them in and install myself, paying only for space, electricity and bandwidth - so it's a different scenario. In the past I was renting virtual and dedicated servers from web hosting companies, from $20/month to $200/month. The virtual ones should be sufficient - they'll give you a login to a shared server but it will be virtually separated from other users and will look like your own, and only you'll have access to it. You'll login to it remotely and it will look like fresh installation of Windows where you can run whatever you like. I was using this company in the past: https://www.ionos.com/servers/vps But virtual/VPS servers from Amazon may work just like that. Also Digital Ocean was very popular.
And if you want quick C# code, here is my function that waits until specific time: static async Task WaitUntil(TimeSpan time) { DateTime now = DateTime.SpecifyKind(TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time")), DateTimeKind.Utc); int ms_to_sleep = (int)(time - now.TimeOfDay).TotalMilliseconds + 1000; //Wait until desired time if (ms_to_sleep > 0) { Console.WriteLine(string.Format("{0}. Waiting {1} seconds until {2}", now.ToHH_MM_SS(), (ms_to_sleep / 1000).ToString("0,0"), time.ToString())); await Task.Delay(ms_to_sleep); } }
Thanks Guru! I like the idea of storing the run times. For some reason I thought it would be much more complicated. Seems easy enough.
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.