Usually, on a Linux mail server, over the time the size of /var/spool/mail/root file can increase considerably do to various programs, services and daemons that are configured by default to send notifications to root account mailbox. So published How to Delete Root Mails (Mailbox) File in Linux in this post
Delete Root Mails (Mailbox) File in Linux
However, before actually deleting the root mail messages, first try to read all the root mails in order to make sure that you don’t remove some important e-mail. On console, you can login as root into your system and simply execute mail command which will automatically open root account mailbox for reading. If mail command line utility is not present in your system, install mailx or mailutils package by issuing the below command.
Recommended: How to setup Quad9 DNS in Windows 10 and Linux
# yum install mailx [On CentOS/RHEL/Fedora]
# apt-get install mailutils [On Debian/Ubuntu]
The simplest method to delete the root account mail file is to use Linux stdout redirection to the file, which will truncate the mailbox file, as illustrated in the below example.
# > /var/spool/mail/root
Other variant you can use to truncate the root account mailbox file is to read the content of /dev/null special Linux file (Linux blackhole file) with cat command and redirect the output to root mailbox file, as shown in the below example. Reading the content of /dev/null file will instantly return EOF (End Of File).
# cat /dev/null > /var/spool/mail/root
After truncating the file, inspect the content of the root account mailbox file using cat command, more or less command in order to determine if the content of the file has been successfully erased.
The less command should return END of file immediately.
You can automate the process of truncating the root account mailbox file by adding a crontab job to run each midnight as shown in the below except.
# 0 0 * * * cat /dev/null > /var/spool/mail/root 2>&1 > truncate-root-mail.log
That’s It! If you know any other way of deleting root mailbox, do share with us via comment section below.
- How to Show Asterisks While Typing Sudo Password in Linux
- How to use the Apple Education Store
- How to share Mac internet connection
- How to speed up a slow Mac or Macbook
- How to test a Mac’s speed & performance
- How to install Windows on a Mac with Boot Camp
- Amazon Cloud Drive Review 2018 – A Secure Cloud Storage