I have a bash script that monitors the jobs in a cluster from the output of the LSF queueing system command "bqueues". The script开发者_开发百科 runs fine. Now I wanted to create a crontab entry that calls this script. The problems is that everythinh related with bqueues produces not output at all, what could be the reason?
- Cron jobs do not inherit the login environment of the user. Specifically environment variables set in .login or .profile, etc. will simply not be available. The absolute single most common reason cron jobs fail is that the PATH setting is not what the script writer assumed.
- Cron jobs do not have a stdin associated with them. Whilst cron will not execute the .login/.profile of a user, it will start the shell normally - thus causing the shell's startup file (.cshrc,.bashrc,etc.) to be executed. Also some command used in the cronjob may be relying on a terminal being present. For example, if you are trying to start 'vi' in batch mode, Don't. Instead replace it with ed or sed.
- Cron job output will be sent by Unix mail to the crontab owner
- Permissions on the crontab itself. Many cron implementations will not even look at a crontab if the permissions on the file are set incorrectly. Generally permissions should be extremely tight - with only read/write for the owner, and NO permissions for group or others.
- compare environments by issuing
env
from shell and crontab. - ...
For more debugging tips, see How to debug an issue of cron's not executing a given script -- or other?
精彩评论