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?"
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