4

There is a specific server in the company I work that uses sendmail to send multiple emails to sendgrid. The file /var/spool/mail/root is about 4.9 GB, which is taking more than 50% of the disk usage. Now, is it safe to just delete it? or do a

cp /dev/null /var/spool/mail/root 

to empty it? I don't want to break the email system, and I don't know if emptying that file could make some emails to get lost in the way. I need to delete this file because disk usage is about to get to 95% and I don't want to run out of space. Thank you!

  • You can purge it, emails that are outbound and have not been sent yet will be stored in /var/spool/mqueue. But mailx has d option, read about it in man pages. – Danila Ladner May 04 '18 at 01:05
  • 1
    Yes, but you also should read the mail that comes in, to find out why it is happening. – Michael Hampton May 04 '18 at 03:01
  • I agree with the feedback here. There's a 99.999999999% chance that it's harmless... but for that last final push to 100% certainty, I'd like to know if anything else is configured to use that folder for anything. Perhaps out of an abundance of caution, consider reviewing configuration files to see how/where that folder is being used. – Mike B May 04 '18 at 13:36
  • 3
    BTW You **SHOULD** create email alias to redirect email for `root` to non-privileged user/mailbox. – AnFi May 04 '18 at 19:40

3 Answers3

6

A more secure way to delete the mails is to use a mail client and delete all the messages.

If you are in debian/ubuntu, you can easily install "bsd-mailx".

with mailx you can delete the messages as follow (as root):

# bsd-mailx
...
& d *
& q

The comman d * deletes all messages and q saves the mailbox and quits mailx. You can delete individual messages, too. See manual of mailx.

There are many other command line mail clients, which could be used.

Marco
  • 316
  • 1
  • 6
5

Yes, as others have already said, they should be safe to delete, and yes, the best way is with a mail client.

But... Take a step back and ask yourself why they are there in the first place.

Is there anything important in there that you should know about?

Whatever sent those emails is still sending emails. For each one, configure it to only send important emails (errors and warnings?), and to an inbox that's not treated as a black hole. Then fix whatever's causing them to be sent.

pgs
  • 3,471
  • 18
  • 19
1

It's fine to delete it if you don't need it. If you need it then you can tar it and back it up elsewhere.

Nasir Riley
  • 2,035
  • 8
  • 9