Hello,
I have a synchronization program built on InstantRails v1.6. I need to
have an option that makes my program run daily at a certain time. Thus,
I need a script or something that is constantly running and checking the
time, then when the time is right, do the sync. Is there a way to do
this with InstantRails?
Then you could put the cron script in the 'script' folder of your
rails application and have it call whatever ruby file you need to run
at a particular time. So for example, at 5 pm every night I want to
write 'Closing Time!' to the error log:
Add this line to crontab to run at 5:
00 5 * * * root sh /path/to/your/rails/app/root/folder/foo.sh
In the sh file:
ruby script/foo.rb run
And then in foo.rb you have whatever code you need, in our case:
RAILS_DEFAULT_LOGGER.error(”\n Closing Time! \n”)
I"ve been using rufus-scheduler with great results. It serves the same
function as cron (run a job periodically), but is portable to windows
and is ruby-centric, and efficient on resources since it's not
reloading the rails environment each time a job runs.