@hourly report-if-fail rsync-some-stuffyour script has to produce its output on stdout+stderr, and exit with 0 for success and nonzero for any failure.
Another thing I do is produce reports into static web pages, but sometimes the reports fail e.g., due to transient network errors. In these cases I want to keep the old version. That's what replace-if-success does: If the command succeeds then it replaces its target file with the command's stdout. Otherwise, it leaves the target file untouched. In any case, it returns the underlying program's exit status, so you can also combine it with report-if-fail. (report-if-fail will e-mail the stderr only in this case)
@hourly replace-if-success /var/www/stats.txt gather-some-statistics
Files currently attached to this page:
replace-if-success | 116 bytes |
report-if-fail | 285 bytes |
In the author's view, these short scripts, report-if-fail and
replace-if-success, are too trivial to be subject to copyright. In
the event that you disagree with this assessment, you may also
use these works under the terms of the CC0 license.
Entry first conceived on 4 November 2013, 21:38 UTC, last modified on 20 November 2013, 2:11 UTC
Website Copyright © 2004-2024 Jeff Epler