Cron Wrapper Script
I was having issues with a server’s crontab, but the complexity of the cron commands (with logging and error-catching added to each) made it hard to debug. So I wrote this general cron wrapper script. (It’s built for Ubuntu Linux, should work in any bash shell, but haven’t tested it in other environments.) To use, extract cron-wrap.sh somewhere on the server. Then in your crontab, you call it like so (this example runs every minute):
WRAPPER=/path/to/cron-wrap.sh CRON_LOG=/var/log/cron.log * * * * * $WRAPPER -d "Doing something" -s "/usr/local/dosomething.sh" -l $CRON_LOG &>> $CRON_LOG
It’ll collect all output (regular and error), then dump it as a block into the specified log file.
The trailing 2>> $CRON_LOG
in the example will catch errors in the wrapper script itself; errors in the command are caught by the script.
Run cron-wrap.sh
by itself to see the usage. (There are 3 one-letter arguments.)