Link to home
Start Free TrialLog in
Avatar of Jim
Jim

asked on

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?
ASKER CERTIFIED SOLUTION
Avatar of Julian Parker
Julian Parker
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.

eg:

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.

regards,
Colin

PS: Remember to run the newaliases command after editing the /etc/aliases file.
Avatar of Jim
Jim

ASKER

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.

Colin
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.

cheers
Colin
@Colin
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
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jim

ASKER

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,
Colin