LinuxCommandLibrary

chronic

Silences command output unless it fails

TLDR

Run command silently unless it fails

$ chronic [command]
copy
Verbose mode with stderr/stdout distinction
$ chronic -v [command]
copy
Trigger on stderr output
$ chronic -e [command]
copy
Verbose with stderr triggering
$ chronic -ve [command]
copy
Use in a cron job instead of redirecting to /dev/null
$ 0 1 * * * chronic backup
copy

SYNOPSIS

chronic [options] command

DESCRIPTION

chronic runs a command quietly, showing output only if the command fails (non-zero exit or crash). Part of moreutils. Ideal for cron jobs where you want verbose commands but silent success.

PARAMETERS

-v

Verbose mode: distinguish stdout/stderr, report return value
-e
Stderr triggering: show output if stderr is non-empty

EXIT STATUS

0

Command succeeded with no stderr (in -e mode)
1
Command failed
2
Command succeeded but produced stderr (in -e mode)

BEHAVIOR

- Success (exit 0): output discarded
- Failure (exit != 0): output displayed
- With -e: stderr output triggers display even on success

CAVEATS

Part of moreutils package. Better than redirecting to /dev/null because you still see errors.

SEE ALSO

moreutils(1), cron(8), sponge(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community