Rake Cron Job Error

0/5 * * * * / bin / bash -l -c 'cd / home / mss / ruby ​​/ example && RAILS_ENV = development / usr / local / bin / bundle exec rake check_me_out --silent → / tmp / cron_log .log 2> & 1 '

Above cron throws the error "bash: bundle: command not found ..."

The command works fine from the command line

Any help would be appreciated.

0
source share
3 answers

Ok, so I got this job. Cron does not load profile settings. I had to load bash_profile as part of the commands, and now it works.

0/5 * * * * / bin / bash -l -c 'source ~ / .bash_profile && cd / home / mss / ruby ​​/ example && RAILS_ENV = development bin / rake check_me_out --silent → / tmp / cron_log. log 2> & 1 '

+6
source

I had the same problem.

I solved this when I set the correct RVM path to CRON:

** * * * / bin / bash -l -c 'cd / home / alex / Projects / my_app && & source ~ / .bash_profile && & rvm use ruby-1.9.3-p194-perf && & bundle exec rake RAILS_ENV = development my_tasks --silent -> /tmp/cron_log.log 2> & 1 '

0
source

I also had the same issue when I configured cron on an AWS EC2 server. This was allowed by setting the package path explicitly in the config/schedule.rb file.

 set :bundle_command, "/usr/local/bin/bundle exec" 

This creates an entry in cron, like:

 30 1 * * * /bin/bash -l -c 'cd <app_path> && RAILS_ENV=beta /usr/local/bin/bundle exec rake 'task_name' --silent >> log/cron.log 2>&1' 
0
source

All Articles