mockra

Using Rake for Cron Jobs - 14 Aug 2012


Rake is a great tool in general, and can even be used for running cron jobs. You can use Ruby’s Time class to create rules for when you want your tasks to be run. Here’s an example of how you can setup your lib/tasks/cron.rake file.

https://gist.github.com/3355894

You can then setup crontab to run your rake file every hour, or however often you choose. Here’s an example for setting up crontab to run your file every hour:

0 * * * * bash -c 'cd rails_path; bundle exec rake cron'