davereinhart/fatigue
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
usage: fatigue [--quiet|-q] <cmd> ...
fatigue --help
fatigue runs a given command but suppresses repeated errors. It is intended
to be run from a crontab as a wrapper around a command that sometimes fails
(exits non-zero). fatigue is inspired by chronic(1) of moreutils fame. They
nicely compose on the command-line as "chronic fatigue ..." to perform
complementary behaviour. chronic(1) suppresses output unless the command
exits non-zero and fatigue suppresses non-zero exit codes for repeated
errors. If chronic(1) is too big of a hammer, then use fatigue's --quiet
option. This will print all output _except_ when a repeat error is detected.
When the given command fails for the first time, fatigue will exit with the
same non-zero status as the command. If the same command fails on the next
invocation with the same error (~identical stdout + stderr output), fatigue
exits with success instead. When coupled with fatigue's --quiet option or
chronic(1), this prevents cron from notifying you about the same failure
again. If the same command fails with a different error, fatigue passes
through the non-zero exit status. If the command succeeds after an error,
fatigue's state is cleared. Separate state is tracked for each unique
(command, working directory) pair.
Note that fatigue identifies repeat errors only by comparing stdout + stderr.
Different non-zero exit codes are not treated as different errors if the
output is the same. Furthermore, any timestamps at the beginning of lines
will be ignored for the purposes of comparing output.
Note also that the command's stdout and stderr will be buffered and merged
into stdout when passed through fatigue. This is normally not a problem.
(If it is for you, it's possible to address, so consider improving the stream
handling of fatigue!)
A lockfile is automatically used to ensure that only one copy of a given
command is running at a time, so that state is handled predictably.
State is stored under $XDG_RUNTIME_DIR/fatigue/.
Requires awk(1), flock(1), md5sum(1), perl(1), and tee(1).
Written by Thomas Sibley <https://tsibley.net>.