Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rake Task from Crontab?

Stack:

Apache2

Rails 2.3.8

RedHat Linux

Ruby Enterprise 1.8.7

Got the following rake task in my app user's crontab which is meant to pull records into a database table every 15 min:

*/15 * * * * app_user cd /var/www/apps/my_app/current/ && rake thing:do_stuff RAILS_ENV=production

I can see that the cron daemon is running this task in the cron log, but the database table it's supposed to pull records into doesn't change. This task is working without error when I run it manually in the /var/www/apps/my_app/current directory, and pulls records into the table as I expect it to.

I reset the PATH variable in the crontab to reflect using REE, thinking maybe the default path wouldn't jive with /opt/ruby-enterprise...

How do I get this rake task to actually run with cron?

like image 794
mcmaloney Avatar asked Feb 07 '11 15:02

mcmaloney


1 Answers

0,15,30,45 * * * * /bin/bash -l -c 'cd /var/www/apps/my_app/current && RAILS_ENV=production bundle exec rake thing:do_stuff --silent'
like image 102
NARKOZ Avatar answered Sep 24 '22 01:09

NARKOZ