Cron Wrapper Script

November 14, 2010

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 somewhere on the server. Then in your crontab, you call it like so (this example runs every minute):


* * * * * $WRAPPER -d "Doing something" -s "/usr/local/" -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 by itself to see the usage. (There are 3 one-letter arguments.)