Deleting all mail for a local server account

It happens, cron jobs can and will go wrong occasionally and when they do, they love to send alerts to the job’s owner hoping for a little attention. An alias can always be added to the /etc/alias file directing all of the mail for an address to to /dev/null but most of the time thats a permanent fix to solve a temporary problem.

Sometimes you just log into a server find a job has gone awry and want to quickly empty the mail spool for a user. Luckily I found this little gem this morning:

echo ‘d *’ | mail -N

It allows you to wipe all of the email in a users spool from the command line in one clean sweep.

Leave a Reply

Your email address will not be published. Required fields are marked *