ifinput

Submitted by jm on Fri, 2007-07-06 16:12.System management | Unix

A wrapper command to run another command if there is any output on stdout

Wed, 2001-02-14 15:00

ifinput crontab stdout stderr

Stable

Often Unix system administrators need an easy way to redirect any stderr output generated from crontab entries to a specific email address. With the ifinput binary, it's simple. For example:

20 8 * * * /usr/local/sbin/daily_stuff.sh 2>&1 | /usr/local/bin/ifinput mailx -s "Error: daily_stuff.sh" system-errors@foo.org

Just arrange the crontab entries so that the periodic jobs don't generate stdout unless there's something interesting there. Then redirect stderr to stdout and pipe both to ifinput.

ifinput can be used in a variety of different scenarios, not just cron jobs.
The source code is available here: http://www.generalconcepts.com/resources/software/gctools-1.0.tar.gz
It has a very small footprint and will compile without issue on most unix systems.

Trackback URL for this post:

http://lopsa.org/trackback/1477