Operating System - HP-UX
1834276 Members
2974 Online
110066 Solutions
New Discussion

Deactivate mail notification from root cron to root mail.

 
SOLVED
Go to solution
JMI
Occasional Contributor

Deactivate mail notification from root cron to root mail.

Hello.

We have a forward from root mail to our outlook mail.

We have a cron process/procedure that generates messages each 15 minutes. This messages are sent to root mail, and consequently, to our outlook mail.

We??d like eliminate these cron messages.

Do you know the way to do?

Thanks in advance.
Regards.
5 REPLIES 5
James R. Ferguson
Acclaimed Contributor

Re: Deactivate mail notification from root cron to root mail.

Hi:

If you don't redirect your cron task's output (stdout and/or stderr), then, by default, the output is mailed to "root".

Regards!

...JRF...
Uday_S_Ankolekar
Honored Contributor

Re: Deactivate mail notification from root cron to root mail.

To stop cron job , take out that entry from your cron job by editing it.

crontab -e will open the root cronjob and edit it accordingly.

Or if you don't want to come to your outlook mail then in root's home directory ther should be a .forward file to forward all root mails to your outlook account , remove this file

-USA..
Good Luck..
David_246
Trusted Contributor

Re: Deactivate mail notification from root cron to root mail.

Hi,

As what user does cron run ?
if it is a simple user you can choose to ignore all messages that comefrom that user by adding a line in the /etc/mail/aliases :

userA: /dev/null

If it runs under root you might want to look at the script that gets started by cron. There must be a way to capture the error message within the script.
I don't believe Cron has this feature. I have been looking for it a while back as well, due to a non-existing homedir (user that had a homedir within a package of the cluster).


Best Regs David
@yourservice
Michael Steele_2
Honored Contributor
Solution

Re: Deactivate mail notification from root cron to root mail.

Cron will always automatically mail output for stdout
and stderr to root unless you specifically state in the
command that stdout and stderr are redirected elsewhere.

To disable cron from mailing output to root add the following to the end of the
cron entry:

> /dev/null 2>&1 (this redirects both std. out and std. error)

0 1 * * * /path/command [options] > /dev/null 2>&1
Support Fatherhood - Stop Family Law
John Palmer
Honored Contributor

Re: Deactivate mail notification from root cron to root mail.

cron mails the standard output/error of issued jobs to the owner. The way to stop it is to ensure that the job produces no output.

Either redirect standard output/error to a logfile (if you are interested in it) or to /dev/null if you are not. For example the crontab entry:
* * * * * script
to trash all output becomes:
* * * * * script >/dev/null 2>&1
to append to a logfile:
* * * * * script >>logfile 2>&1

Regards,
John