1820879 Members
4232 Online
109628 Solutions
New Discussion юеВ

how to clear mail

 
Ramana.Sv
Frequent Advisor

how to clear mail

hi iam using hp-ux system , everyday i run crontab, after completeing the job, when login its showing, you have mail then when i press mail its showing so many mail i want clear al the mail how to???
6 REPLIES 6
Torsten.
Acclaimed Contributor

Re: how to clear mail

A "clean" way:

run "elm", mark all mails to be deleted "d", "q"uit elm and answer "y"es, I want to delete them.

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
whiteknight
Honored Contributor

Re: how to clear mail



Ramana,

You can clearn the mail by nullify


# > /var/mail/root

WK
Problem never ends, you must know how to fix it
Torsten.
Acclaimed Contributor

Re: how to clear mail

Of course you can delete all messages at once, but consider this:
By default the system will inform root via mail about events (for example hardware problems). If you delete all mails, you may miss important notifications. Keep an eye on this mailbox!

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
Patrick Wallek
Honored Contributor

Re: how to clear mail

The better way is to set up an alias for root in /etc/mail/aliases so that all root e-mail gets forwarded to your regular address.

Excerpt from aliases:

root : you@yourdomain.com

After you modify /etc/aliases you need to run the 'newaliases' command.

Now all root mail will go to you@yourdomain.com.
Dennis Handly
Acclaimed Contributor

Re: how to clear mail

>everyday i run crontab, after completing the job, you have mail

The right way to solve this is to only generate mail if there is something wrong.

You can do this by sending or appending the crontab output to a file. And then browse it if these are low priority issues.

Or make sure your script doesn't send any output unless you need to know about it.

You can of course redirect stdout and stderr to /dev/null:
... > /dev/null 2>&1
Gaurav_Goyal
New Member

Re: how to clear mail

Hi,
If you are logged in by root then delete file /var/mail/root or if anyother username then delete respective file for ex.
if user 'xyz' then delete /var/mail/xyz file.

OR if you dont want mail after execution of cron job then redirect stdout and stderr to /dev/null:... > /dev/null 2>&1
This way you wouldn't get mail after execution of cron job.