Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cron Jobs and Email 3

Status
Not open for further replies.

Michael42

Programmer
Oct 8, 2001
1,454
US
Hello,

On a Solaris 8 system I have a cron job that runs as root and sends it's output to the root's email address.

I have nothing in the cron job that generates the email. It seems to be comming from the system itself.

How can I set all my cron jobs on this system so as they do not generate emails?


Thanks,

Michael42
 
If the program/script/command that the crontab runs generates any output it'll send an email of the output to the root alias (or the user if it's a user crontab). The easiest way I know to stop this is to redirect any output of the program to /dev/null or a log file if you want to keep it.

Depending on what it is you may want to write some logic into the script that only throws output if there's a problem with the execution of the script. Then at least you know if it's not working.

Brian
 
z28sarefun is right, but here's just an example crontab to further clarify...

* * * * * /yourscript > /dev/null
 
coohand's method will email you if there is an error. If you don't want an email regardless of an error (for example, if you are creating a log file within your script that you will check to make sure everything was OK), use this:

* * * * * /yourscript > /dev/null 2>&1
 
Great!

Thanks all for your very useful advice.

Thanks,

Michael42
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top