Constantly Running a Script

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?

Any help is appreciated!


  • Jeff M.

That’s more of an OS function than a rails function isn’t it? So–on
windows that’d be a scheduled task. Or do I misunderstand the goal?

Might want to read through some of these articles to set up a cron:

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/

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”)

Hope this helps!


On May 1, 2:00 pm, Jeff M. [email protected]

I think Cron will work. I just have to flesh out everything around it
before I test it. Thanks!!

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.

I’ve been trying to use the Rufus-Scheduler, but no luck so far with it.
I have this in one of my controllers:

scheduler.schedule “* #{params[:month_time]} #{params[:month_date]} * *”
ruby script/push2exchange.rb run

then the error I get is:

Errno::ENOENT in AutosyncController#index
No such file or directory - crontab -l

I am running InstantRails 1.6 on Windows Server 2003. Is this error the
result of it being on Windows? If so, how can I fix it?

Any help is appreciated!


  • Jeff M.