chronic1
Runs a command quietly unless it fails
Usage
chronic [-ev]
COMMAND ...
Overview
chronic runs a command, and arranges for its standard out and standard error to only be displayed if the command fails (exits nonzero or crashes). If the command succeeds, any extraneous output will be hidden.
A common use for chronic is for running a cron job. Rather than trying to keep the command quiet, and having to deal with mails containing accidental output when it succeeds, and not verbose enough output when it fails, you can just run it verbosely always, and use chronic to hide the successful output.
0 1 * * * chronic backup # instead of backup >/dev/null 2>&1*/20 * * * * chronic -ve my_script # verbose for debugging
Options
-
-v -
Verbose output (distinguishes between STDOUT and STDERR, also reports RETVAL)
-
-e -
Stderr triggering. Triggers output when stderr output length is non-zero. Without -e chronic needs non-zero return value to trigger output.
In this mode, chronic's return value will be
2if the command's return value is0but the command printed to stderr.
Releases
8 releases since Debian 7 (Wheezy); the text changed 7 times.
-e since Debian 9 (Stretch);
-v since Debian 9 (Stretch).