How to delete all mail at once?

Hi guys,

I have 459 mails sent to me by cron. I stopped the service and I will like to delete all the mail.

Is there a command I can use to delete all my mail at once?

Thanks guys

Maybe something like this, but I'm not sure is this the best way.

# cd /var/mail
# > root

I assume that we are talking about root account.
You can backup this file before you clear it.

I remember having the same issue with Solaris 10 SPARC a long time ago. For some reason I now use 'mailx' command not 'mail' to achieve this.

I don't know why 'mail' command doesn't do this but for sure someone on this forum will tell us.

Hope that helps somewhat.

Wasn't comfortable with deleting the text file /var/mail/root however deleting the mail with mailx seems to delete this file anyway.
OK just had a brief look at mailx, this worked for me to delete 27 messages to root (numbered id 1 to 27).
Note the mailx commands aren't exactly the same as mail, but still use "?" to get help to get the list of valid commands.

# mailx
? delete 1-27
? head
No applicable messages
? q
#

Saw from the help, type "?" to get a list, need to use "q" to exit not "x". I used "x" to exit the first time and the messages didn't get deleted as "x" is quit but preserve all messages. "q" is quit preserving unread messages.

Hope this helps somebody.