Page 1 of 1

/var/spool/mail/root How to read the mail?

Posted: Wed Oct 19, 2011 11:34 am
by VinceVDC
This is such a n00b question.....
The /var/spool/mail/root file is growing larger every day. I'm assuming that the messages in there are important or they wouldn't be sent. Is there some way I can forward them to another account? Is there a mail reader buried in Nagios XI for this? Or is it safe to ignore the generated mail?

Re: /var/spool/mail/root How to read the mail?

Posted: Wed Oct 19, 2011 2:55 pm
by lmiltchev
Reading root mail:

You can read root's mail by running this command in terminal:

Code: Select all

#  cat /var/spool/mail/root | less
Scroll down to read all of the messages.

If you want to see only the last 10 messages, you can run:

Code: Select all

#  tail /var/spool/mail/root
Or you can save all of the root's mail by redirecting it to a file,
which you can review later, for example:

Code: Select all

#  cat /var/spool/mail/root > rootmail.txt
You can also set it up so it will be resent to a different e-mail:

Code: Select all

# vi /etc/aliases
Note: You can use a different text editor (besides vi) if you are more
comfortable.

Scroll down. Close to the end of the file, you should see something like
this:

Code: Select all

# Person who should get root's mail
root:
Type your e-mail, so it will look like this:

Code: Select all

# Person who should get root's mail
root:	my_email@my_company.com
Save the file and type in terminal:

Code: Select all

# newaliases
Hit "Enter" to apply changes.

Here's the link to the CentOS forum, dealing with root mail:

https://www.centos.org/modules/newbb/vi ... ic_id=5674

Deleting root's mail:

You can also delete all of the messages in your root's mail by running in terminal:

Code: Select all

# cat /dev/null > /var/spool/mail/root
Hope this helps.