Search code examples
ruby-on-railscronrake

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 an error "bash: bundle: command not found..."

The command works just fine from the command line

Any help will be appreciated.


Solution

  • Okay so I got this working. Cron does not load the profile settings. I had to load the 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'