Linux Sendmail issue - ROOT mail is growing do not know how to clear out to control storage use

Inherited a sendmail server; how can I empty ROOTs email which has been creeping up in storage for months.  Can I use the /dev/null process to empty ?  Any suggestions?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

joolsSenior Systems AdministratorCommented:
Send all root email to a normal user, edit /etc/aliases and change the root:  to a valid username like;

# Person who should get root's mail
root:           myusername

then run newaliases, you should then get all root's email.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Hi there,

Any new mail sits in /var/spool/mail/<USERNAME> by default.
After being read, it is MOVED to to $HOME/mbox by default.


If you do not want any of the unread mail, just rm the /var/spool/mail/<USERNAME> file. In this case, run the following:
 rm -f /var/spool/mail/root

If you do not want any of the read mail, just rm the $HOME/mbox file. In this case, run the following command:
 rm -f $HOME/mbox

This is that fastest way to clear the mailbox, HOWEVER, YOU MUST BE SURE YOU WANT NOTHING IN THE MAILBOX FIRST.

Hope that helped.
Hi there,

jools is correct, if you want to make root's mail sent to a different mailbox (one that is checked on a regular basis) you should edit the /etc/aliases file.

You can also place a full email address next to root in order to get it to send it off server.


root:    me@myco.tld

You will just need to ensure that DNS is working and that the server's MTA can relay mail out.
to check this you can test an outbound email. Run the following:

 echo "test mail body" | mail -s "Test Subject" me@myco.tld & tail -f /var/log/maillog

The above command will create an email destined for me@myco.tld and then start tailing the maillog file. This should tell you if it worked or not.


PS: Remember to run the newaliases command after editing the /etc/aliases file.
Newly released Acronis True Image 2019

In announcing the release of the 15th Anniversary Edition of Acronis True Image 2019, the company revealed that its artificial intelligence-based anti-ransomware technology – stopped more than 200,000 ransomware attacks on 150,000 customers last year.

JimTechAuthor Commented:
On our sendmail the ROOT does NOT have a standard mailbox such as all the other userid's.  For example every other user has a /home/mail which has the users (sent; sent-mail; drafts... etc).  However all that ROOT has is going directly under /mail/root which has 500mb of data in that file (no home directory). No one has ever been able to view or access the ROOT email therefore it's building up.

However to your point both /var/mail/root and /mail/root - have the exact same amount of data (500mb) I assume it's essentially the same file.  I don't want to REMOVE but just empty the data in the ROOT for now hence my reason for asking about "emptying" root but retaining it.  Since I assume is the most critical email-id.  

My thought was the following:
./sendmail stop
cp /dev/null /mail/root

This should empty the 500mb's - ???? thoughts????
Hi there,

From what you have said, you want to keep a cop of the mail within root's mailbox (/mail/root) for viewing later.

In order to achieve this, you could copy that file to a new location and then setup a symlink to /dev/null to dump any new email generated into /dev/null (rendering it - for the lack of a better word - gone!)

0) /etc/init.d/sendmail stop
1) mv /mail/root /other/location/root.old.mailbox
2) ln -s /dev/null /mail/root

Let me know if you need anything else.

joolsSenior Systems AdministratorCommented:
Redirect it using the mail aliases file as shown above. You should be checking root's email so you will really need to do this then it wont build up and you wont have the problem.

you can view the root mail by logging in as root and using mutt or if youre a real die hard just vi/nano it and look at it before you kill it. you should not have to stop sendmail just to delete the root mail file...
Hi there,

jools: the only reason I recommended the service be stopped is because I was running two commands an mv and then a ln. between this time if an email was to be delivered it would create a new /mail/root file and the ln command would fail. Is there a better (safer) way to do this?

pmcinc: Please remember to start the service again after you execute the above. I forgot to add the line to start the service again. :)

jools is right though, you really should be checking this mail and not just throwing it away :( Redirection is the best option.

joolsSenior Systems AdministratorCommented:
Hi Mate, I hadnt seen your post when I posted my comment. You are of course right that the ln would not have worked in your case. I was posting in response to http:#a24466632
you can always truncate files with

cp /dev/null /path/to/file (which you mentioned earlier).

It is better if you could read these emails since it could contain some info related to running scripts or crontab jobs. This could be done with running the below command as root


You may try to see why your root mail box is growing and fix that (check crontab jobs with crontab -l and see which job could be generating output and fix that)
JimTechAuthor Commented:
Jools and Colinvann:  I believe both of you are on target and I'm about to create an ALIAS for ROOT to a special email ID called EADMIN that I can monitor daily.

My question is we use LINUXCONF for just about all SENDMAIL changes since we are not Linux experts.  MY question is can I use the email-alias under LINUXCONF to create the alias for Root?  We use that same option for all other email alias's but wanted to be sure that it would work for ROOT?  

Also since ROOT has never been VIEWED my assumption is once I ALIAS to eadmin and pull off the server ROOT will be essentially flushed clean and we'll no longer have this issue of ROOT growing to excessive storage amount.
Please advise ...
Thank you both so far for you support and assistance.
Only new mail that is processed will be sent to the root's alias. if you want to view root's current mail, then you will need to user a mail client (mutt/mail for example) to view roots mail directly.

If you would like to have the new account to have all roots older mails, you will have to copy the /var/spool/mail/root file to /var/spool/mail/eadmin and make sure that eadmin has rights to that file:
  cp /var/spool/mail/root /var/spool/mail/eadmin
  chown eadmin.eadmin /var/spool/mail/eadmin

I'm not sure about linuxconf, sorry, I do all/most of my changes directly. But there is no reason (that is glaringly obvious to me) not to try and do it and see if it will work :) if it doesn't, then it doesn't. If it does, then you have come right :)

You can send a test mail to the root account by running the following command:
  echo | mail -s 'test' root

You can then check to see if it worked by either checking the maillog (/var/log/maillog) ot by checking the inbox of eadmin.

hope that helped,
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.