Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

This question already has an answer here:

This is the contents of my crontab file:

0 0,6,12,18 * * * cd /var/www/app/current && backup perform --trigger db_backup --config_file config/backup.rb --data-path db --log-path log --tmp-path tmp >> /var/www/app/current/log/cron.log 2>&1

0 3 * * * cd /var/www/app/current && RAILS_ENV=production bundle exec rake runs:populate --silent >> /var/www/app/current/log/cron.log 2>&1

59 23 * * * cd /var/www/app/current && RAILS_ENV=production bundle exec rake runs:log --silent >> /var/www/app/current/log/cron.log 2>&1

If I run any of these manually as the owner of the crontab they work fine, but the cron.log file simply contains:

/bin/sh: bundle: not found
/bin/sh: backup: not found
/bin/sh: bundle: not found

I tried wrapping each one in the following (as default by the whenever gem which I'm using to manage my cron file) bash -l -c '...' but then I get the same as above except for bash bash: bundle: command not found

share|improve this question

marked as duplicate by Iain, Jenny D, Tom O'Connor May 13 at 14:13

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

add comment

2 Answers 2

up vote 12 down vote accepted

The deafult PATH for CRON jobs is usually /usr/bin:/bin. Your commands bundle and backup are likely not in the default path. One solution is to change your crontab and include the full path to these commands.

0 0,6,12,18 * * * cd /var/www/app/current && /path/to/backup ...

etc. In general it's a good idea to use full paths in crontabs. If you want you can also specify the PTH inside the crontab

PATH=/bin:/usr/bin:/path/to/your/program

0 0,6,12,18 * * * cd /var/www/app/current && backup ...
share|improve this answer
    
Is there a way to add to the default path for cron so I don't have to provide the full path for each command? –  DEfusion Oct 5 '11 at 10:09
    
Yes you can specify a PATH in the crontab file - see my edit –  Iain Oct 5 '11 at 10:18
add comment

Yes, you can set path before actual crontab records, eg:

PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:
0 3 * * * run-cron-job
share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.