Search code examples
bashcronqueuelsf

LSF queueing output in crontab problem


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?


Solution

    1. 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.
    2. 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.
    3. Cron job output will be sent by Unix mail to the crontab owner
    4. 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.
    5. compare environments by issuing env from shell and crontab.
    6. ...

    For more debugging tips, see How to debug an issue of cron's not executing a given script -- or other?