Re: How to stop a cron job sending email
- From: Karl Auer <kauer@xxxxxxxxxxxxxx>
- Date: Sat, 01 Nov 2008 01:37:05 +1100
On Fri, 2008-10-31 at 15:21 +0200, Johann Spies wrote:
It can be something like:
fetchmail: No mail for johann.spies@xxxxxxxx at mail.wo.co.za
fetchmail: No mail for security@xxxxxxxxxxxxx at alterit.co.za
fetchmail: No mail for webmaster@xxxxxxxxxxxxx at alterit.co.za
fetchmail: No mail for johann.spies@xxxxxxxxxxxxx at alterit.co.za
The right way to deal with this is to change your script so that it
pipes its results into (say) grep:
#!/bin/sh
killall -q fetchmail
/usr/bin/fetchmail | grep -iv "No mail for "
That way there will be no output generated if everything works as
expected.
With egrep you can scan for more than one expected result. Or you could
use a chain of greps.
killall outputs nothing if it successfully kills things. "-q" tells it
not to report that no processes were killed. If anything else happens,
you will be informed. There may be a similar switch for fetchmail, which
would save using grep.
If expected messages are going to stderr instead of stdout you have to
use a syntax that is slightly less well known. For example, to capture
the "no process killed" message from killall (instead of using "-q"):
killall telnet 2>&1 | grep -iv "no process killed"
One day your script will output something different: "fetchmail: Oops!
Major problem! You have eight hours to act before your hard disk is
wiped and your pets are shaved!"
Because that doesn't match the regexp, it will be output and thus mailed
to you in time for you to save the day.
Regards, K.
PS: Untested code above - just typed in, never run.
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Karl Auer (kauer@xxxxxxxxxxxxxx) +61-2-64957160 (h)
http://www.biplane.com.au/~kauer/ +61-428-957160 (mob)
GPG fingerprint: DD23 0DF3 2260 3060 7FEC 5CA8 1AF6 D9E3 CFEE 6B28
Attachment:
signature.asc
Description: This is a digitally signed message part
ubuntu-users mailing list
ubuntu-users@xxxxxxxxxxxxxxxx
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
- References:
- How to stop a cron job sending email
- From: Johann Spies
- Re: How to stop a cron job sending email
- From: Karl Auer
- Re: How to stop a cron job sending email
- From: Johann Spies
- Re: How to stop a cron job sending email
- From: Avi Greenbury
- Re: How to stop a cron job sending email
- From: Johann Spies
- How to stop a cron job sending email
- Prev by Date: Re: about 3d and transparent desktop?
- Next by Date: Re: How to stop a cron job sending email
- Previous by thread: Re: How to stop a cron job sending email
- Next by thread: Re: How to stop a cron job sending email
- Index(es):
Relevant Pages
|