I have a crontab task running every 5 minutes. It writes an output (result of the .sh file run by the crontab) to the /var/spool/mail/user. Should I be worried that this spooler will build up and slow down the system over time? Do these entries ever get cleared out? Are they only temporary? If possible, can I disable it.
The messages stay there until the user whose mail it is reads and deletes the mail. That might be years later (I kid you not!).
- No, the directory is not cleared out by anything.
- Yes, you need to be worried about the problem of filling up your disk with unread email.
The contents of the /var/spool/mail/user directory remain until the user deletes the mail. You may wish to install a script that runs via cron to remove files older than a certain date, and tweak this as you monitor your system.
I added this line to crontab to my user root:
* */2 * * * /bin/su - root -c cat/dev/null > /var/spool/mail/root
So every 2 hours, it is cleaned for that specific user (root).