From 2048bb113a8028ed340150e17c1bfc9fd90d31ef Mon Sep 17 00:00:00 2001 From: Matt Amos Date: Wed, 31 Dec 2014 13:11:01 +0000 Subject: [PATCH 1/1] Send email from planetdump script. It seems that incron doesn't yet support sending email directly using something like cron's `MAILTO` environment variable [1], but I'd like to see the output to ensure that everything has gone smoothly. [1] http://inotify.aiken.cz/?section=incron&page=faq (see "Q: Can I catch outputs of executed commands?" --- cookbooks/planet/templates/default/planetdump.erb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cookbooks/planet/templates/default/planetdump.erb b/cookbooks/planet/templates/default/planetdump.erb index d891fc2ea..dff206b35 100644 --- a/cookbooks/planet/templates/default/planetdump.erb +++ b/cookbooks/planet/templates/default/planetdump.erb @@ -26,12 +26,23 @@ if [ -f /tmp/planetdump.lock ]; then fi fi +# Redirect this shell's output to a file. This is so that it +# can be emailed later, since this script is run from incron +# and incron doesn't yet support MAILTO like cron does. The +# command below appears to work in bash as well as dash. +logfile="/tmp/planetdump.log.$$" +exec > $logfile 2>&1 + # Create Lock echo $$ > /tmp/planetdump.lock # Define cleanup function function cleanup { rm /tmp/planetdump.lock + # Send an email with the output, since incron doesn't yet + # support doing this in the incrontab. + /usr/bin/mailx -s "Planet dump output: ${file}" zerebubuth@gmail.com < $logfile + rm $logfile } # Remove lock on exit -- 2.43.2