There are many ways to delete cron mails and empty the inbox which is filled by cron job every time it runs. Some time we are running multiple scripts/files every minute. So cron send mail for that specific user to inform about the cron task and the mail, if there is any thing to output, it will be in the mail.
But some time we don’t want any mails created by cron to send. Its because we know our scripts are running fine.
I am going to mention three methods here.
Method-1: Running a simple command in terminal,
1- Open terminal and became any user, you want to delete mails from his/her inbox.
2- This way will clear all the inbox.
3- Write the following command in terminal now:
cat /dev/null >/var/mail/username
Change username in above.
Method-2: Running a bash script in terminal,
1- Open any of your text editor and write the following code in it:
echo ‘d *’ | mail -N
2- Save it as any file name you want, i would save it cron.sh.
3- Now run it in terminal like this:
Remember to give correct path in the above line.
Method-3: Another way is to delete one by one, but that will be pain in the neck if you have hundreds or thousands of mails in the inbox. But if you want to delete a specific message so you can do it like this way, 1st enter to the user mail directory for example:
Path and username can be changed according to user and distribution.
d 1 2 6 10
The above line will delete messages 1,2,6,10 respectively by using the ‘mail’ command.
Hope it would help.