-
Notifications
You must be signed in to change notification settings - Fork 726
Troubleshooting
Index:
- No job gets executed on Ubuntu with RVM
The typical setting for ~/.bashrc on Ubuntu disable everything when the shell is not interactive. You should find the following two lines inside ~/.bashrc of your user:
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
The only fix is to comment them out.
If that still doesn't make things happen, you might try whenever --clear-crontab
. I don't have proof but it seems to have worked for me.
I discovered that my cron jobs were failing via the internal mail that is sent by cron. The error message indicated that the shell could not find any ruby in the environment: /usr/bin/env: ruby: No such file or directory
The solution is to include a PATH in the crontab above the job schedules.
PATH=/opt/local/ree/bin:/bin:/sbin:/whateverpathyouneed
You can also set the PATH in your schedule.rb
env :PATH, '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin'
So you do not have to retype your PATH, you could write this in schedule.rb:
env :PATH, ENV['PATH']
I had a similar issue in my production environment (WebFaction) and used "env" to set several Environment Variables before cron runs my Ruby methods.
env 'GEM_HOME','/home/web_faction_username/webapps/web_faction_app_name/gems'
env 'RUBY_LIB','/home/web_faction_username/webapps/web_faction_app_name/rails_root_dir/lib'
env 'PATH','/home/web_faction_username/webapps/web_faction_app_name/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/web_faction_username/bin'
If you are using "set environment=" when using the whenever command, this configuration can be nested nicely to make it environment-specific using:
case @environment
when 'production'
...
end
end
If you have problems with Whenever failing to run after adding to a project and then deploying, it's likely because it's trying to run before bundler. You should ensure you're using the latest bundler and then require whenever after bundler in your deploy.rb
If that doesn't work or isn't possible you can do something similar to the following: (See thread on PR 324 - https://github.com/javan/whenever/pull/324)
# manual to influence later execution time
#require 'whenever/capistrano'
require 'whenever/capistrano/recipes'
after "deploy:finalize_update", "whenever:update_crontab"
after "deploy:rollback", "whenever:update_crontab"