Posted at

Rails: run rake task in cron jobs

More than 5 years have passed since last update.

In Rakefile, add this line to the top:

#!/usr/bin/env rake

Run crontab -e to access crontab editor

* * * * * cd /path/to/rails_app; bin/rake some_task

Change the timing, path to your rails app and the rake task that you want to execute.

Read more:

(note: in the tutorial, the author suggests to use full path to rake. I tried but it failed so I just used bin/rake instead)