1753363 Members
5442 Online
108792 Solutions
New Discussion юеВ

Re: cron question

 
SOLVED
Go to solution
Eric Harvill_1
Occasional Advisor

cron question

Is there a way to prevent a single cron entry from sending an email whenever it completes? Thanks...

Eric
5 REPLIES 5
Uday_S_Ankolekar
Honored Contributor

Re: cron question

redirect the output to file or then use mailx to send it as a e-mail. Or write a script to do cron job and send e-mail after competion of job
Good Luck..
A. Clay Stephenson
Acclaimed Contributor

Re: cron question

Hi Eric,

The easist thing to do is redirect your scrit's stdout and stderr to /dev/null.
If it ain't broke, I can fix that.
Eric Harvill_1
Occasional Advisor

Re: cron question

I've actually tried that and it doesn't seem to be working. Perhaps my syntax is wrong? Here is the entry:

15,30,45,00 * * * * /opt/sysadm/bin/check_printer atlpsih8k1 2>&1 /dev/null

Thanks.

Eric
Bill Hassell
Honored Contributor
Solution

Re: cron question

Not wuite the correct syntax to redirect all output to /dev/null. The correct syntax is to first redirect stdout and then assign stderr to stdout:

...check_printer atlpsih8k1 1>/dev/null 2>&1

It must be in that order as the shell assigns things as it parses them, left to right. 2>&1 followed by > /dev/null means that stderr would be assigned to whatever stdout was, and then stdout is assigned /dev/null (stderr is still assigned to the original output file).


Bill Hassell, sysadmin
Eric Harvill_1
Occasional Advisor

Re: cron question


Bill, thank you for the correct syntax.