![]() |
| |||||||
![]() |
| | LinkBack | Thread Tools | Search this Thread | Display Modes |
| |||
| Rahul wrote: > I would like to have cron run a command and then send me an email *only* if > the command produces some output. I wrote the command to be silent normally > but it produces output only when things go wrong. When they do go wrong I'd > like to hear about it. Something like: > > 15 * * * * fullpath/my_command.sh 2>&1 | mail -s "strange cron op" > "me@xxx.xxx" > > That's not so good because it always sends me an empty email even when > things are OK. One solution would be to save the output to a file, and send its contents only if it's non-empty: my_command.sh > /tmp/c$$ 2>&1; [ -s /tmp/c$$ ] && mailx -s "subject" < /tmp/c$$; rm -f /tmp/c$$ Heiner -- ___ _ / __| |_ _____ _____ _ _ Heiner STEVEN <heiner.steven@nexgo.de> \__ \ _/ -_) V / -_) ' \ Shell Script Programmers: visit |___/\__\___|\_/\___|_||_| http://www.shelldorado.com/ |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |