CyberKeeda In Social Media

Ignore or stop cron mail to users using >/dev/null 2>&1

Crond comes with it's default policy of sending mails to root after the proper execution of cronjobs with given specific interval.
Now take an example, if you have to set a cron job for every 5 minutes, then crond will send emails to root's or user's mail directory the same no of times of mail.
It  means for every successfully cronjob excution it will send a mail and the mail directory keeps on increasing without any notification.

Sometimes it required and sometimes not, so if you don't need those cron mails then use the below mentioned strings after your cronjob entry.

 >/dev/null 2>&1 

Example --: This will stop crond to send mails every minutes

*/5 * * * * /tmp/ >/dev/null 2>&1 

-- Description --

> is for redirect

/dev/null is a black hole where any data sent, will be discarded

2 is the file descriptor for Standard Error

> is for redirect

& is the symbol for file descriptor (without it, the following 1 would be considered a filename)

1 is the file descriptor for Standard Out

No comments:

Post a Comment

Designed By Jackuna