0

I recently changed from rvm to asdf. Since then, I can't get cronjobs to run.

crontab -l

* * * * * /bin/bash -l -c 'cd /var/www/jobs/code && RAILS_ENV=production bundle exec rake cron_test' >> /tmp/cron_test_output 2>&1 /tmp/cron_error

gives me /tmp/cron_error: bundle: command not found. There is no output to stderr.

gem install bundler has not worked for the jobs user.

Not sure where to install bundler to make this work. The rake tasks work when run independently. The cronjobs that are not rake tasks run. Cron is working.

Edit:

While the cronjobs were working before, they obviously can't now find the location of bundler. By changing bundle exec to the full path /home/jobs/.asdf/shims/bundler exec, I have managed to get this to work.

Flux
  • 9,805
  • 5
  • 46
  • 92
smilingfrog
  • 376
  • 3
  • 14

1 Answers1

0

I have been using the whenever gem to create cron jobs for rake tasks. Turns out the easiest way to get around this problem is to make sure that the environment path is included in the whenever generated crontab.

within config/schedule.rb for the whenever gem, I added the following:

env :PATH, ENV['PATH']

and now everything is working as the cron job can now find the bundler.

Based on this issue from the whenever gem.

And this one too.

smilingfrog
  • 376
  • 3
  • 14