1753500 Members
4156 Online
108794 Solutions
New Discussion юеВ

Mails

 
Ali Imran Abbas
Regular Advisor

Mails

I am just doing a routine cleanup on my systems and I found big mail files under var/mail directory specially for root and oracle users. I have a questios in this regard, do we need these files for reference or periodically trim them? What is the procedure to trim or delete these files.

6 REPLIES 6
Ivan Krastev
Honored Contributor

Re: Mails

You can trim files with:

> /var/mail/root
> /var/mail/oracle


regards,
ivan
Patrick Wallek
Honored Contributor

Re: Mails

You really should be looking at those e-mail messages BEFORE you clean up the files.

Those 2 files you mention contain the local system e-mail for those 2 users. There could potentially be VERY important system or database related messages there.

Ideally you should have aliases set up for those users so someone gets those messages.
Jeeshan
Honored Contributor

Re: Mails

salam Imran

either you can rm the files in /var/mail folder.
a warrior never quits
James R. Ferguson
Acclaimed Contributor

Re: Mails

Hi:

If you don't want any of the contents, as noted, you can do:

# > /var/mail/oracle

or:

# cat /dev/null > /var/mail/oracle

or:

# rm /var/mail/oracle

Either of the first two forms result in an empty file.

If you believe that you might want the contents for reference, you could 'gzip' them as compressed files and move them elsewhere.

You could also delete (e.g. with 'vi') some number or range of messages where a message stanza begins with "^From".

Regards!

...JRF...
Regards!

...JRF...
James R. Ferguson
Acclaimed Contributor

Re: Mails

Hi (again):

I wonder if you don't really need to cleanup some of the processses that are *creating* the mail in the first place.

For example, if you have 'cron' tasks that 'su -' to oracle, then the account's profile is being sourced (read) and any terminal based commands meant to be run in a terminal-associated environment are producing annoying "Not a typewriter" messages to STDERR which (by default under 'cron') get mailed to the user account.

One solution in that case is to modify your '.profile' to be sensitive to this by conditionally adding:

# if [ -t 0]; then #...interactive/not cron...

to create a a conditional block around the code that does 'stty', 'tset' and 'tabs' commands in the standard profile.

Regards!

...JRF...
Dennis Handly
Acclaimed Contributor

Re: Mails

>JRF: You could also delete (e.g. with 'vi') some number or range of messages where a message stanza begins with "^From".

Instead of using vi, you can use "mailx -f /var/mail/root" (or "mailx -u root") to look at these mailboxes.
There are simple commands to delete ranges and read the messages.