[Tip] How to add an application cron job?

A well established form of application cron jobs look like this:

39 15 * * * [ -x /usr/local/monitoring/oracle/check_dbs.sh ] && /usr/local/monitoring/oracle/check_dbs.sh >/dev/null 2>&1

The repetition makes it a long line, hard to read, hard to maintain.
I suggest the following instead:

39 15 * * * { /usr/local/monitoring/oracle/check_dbs.sh ; } >/dev/null 2>&1

Should work even with the oldest Bourne shells.
Don't miss the semicolon between the command and the closing brace! The shell syntax requires it. Also the braces must be separated with a space character.

4 Likes

Very good tip. Thank you.

I have added "[Tip]" in the title to make it easier to find it.

bakunin