I run a lot of scripts from cron, and only want to hear about them when they fail. That's precisely what this script does. Just insert it at the start of your cron command, e.g.,
@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:
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.
A number of times, I've said that I like the Windows 7 feature that allows a window to easily be half-maximized. I got tired of waiting for it to be added to my favorite window manager, so I wrote a script that uses the program wmctrl to half-maximize windows, then bound it to key presses in my window manager. Now, with a press of ctrl+alt+[QWER], I can half-maximize a window into 4 locations on my dual-monitor setup.
All older entries
Website Copyright © 2004-2018 Jeff Epler