Re: Silent maintenance
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Aug 14, 2010, 21:41 UTC
- Message-ID
- <AANLkTimLHand0g965TJmk=Y4Q+0uTFovZZRZXf9Fx4UB@mail.gmail.com>
- In-Reply-To
- <20100814210556.GB2372@burratino>
On Sat, Aug 14, 2010 at 21:05, Jonathan Nieder <jrnieder@gmail.com> wrote:
Show 6 quoted lines
> Enrico Weigelt wrote: > >> are there some flags to make the maintenance commands like >> git-repack and git-gc silent, so they only output errors ? > > Does --quiet work? If not, patches would be welcome.
I intentionally neglected to mention that. That inevitably leads to cases where something fails, but you didn't record the output.
Instead (copy/paste from a recent post of mine to an unrelated mailing list, funny how these things come up at the same time), do:
Just install this: http://search.cpan.org/dist/App-Cronjob/
Then put something like this in your crontab:
@daily cronjob -E -j josm-build -E /path/to/build.sh
cronjob(1) will consume all the output, and either print it all or nothing, depending on the exit code of the program it's running.
If you're running a POSIX shell script you can add this to the top of the script:
# Exit on errors
trap 'fail' ERR
fail () {
code=$?
echo "Failed with exit code $code"
exit 1
}Then you don't have to check the exit code of everything individually.
I use this for all my cronjobs, see e.g. http://github.com/avar/openstreetmap-mirror for an example, it's what I use to get E-Mails when the JOSM GitHub mirror fails, but *only* when it fails.