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 4 '18 at 1:05
  • 1
    Yes, but you also should read the mail that comes in, to find out why it is happening. – Michael Hampton May 4 '18 at 3: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 4 '18 at 13:36
  • 3
    BTW You SHOULD create email alias to redirect email for root to non-privileged user/mailbox. – AnFi May 4 '18 at 19:40

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.

| improve this answer | |

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.

| improve this answer | |

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.