Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

As a result of a long-running cron job, I have over 1,000 messages in my user's mailbox. What's the easiest way to delete them?

share|improve this question
add comment

2 Answers

up vote 15 down vote accepted

If you want to delete all the messages, you can simply truncate the mailbox file for a user with the following command:

> /var/mail/username

(the greater than sign is not a prompt: you are in effect redirecting the output of nothing to the file, which will truncate it).

share|improve this answer
    
I didn't have permission to do this on my own mail but for some reason echo > /var/mail/username did work to the same effect. –  nickv2002 Mar 23 at 19:03
    
That is surprising. You didn't leave out the leading > by any chance? –  James Henstridge Mar 24 at 1:33
    
Checked my history, I didn't forget the > it was actually just a typo on my username the first time I tried. Oops! Thanks though. –  nickv2002 Mar 24 at 5:02
add comment

Did you try sudo rm -rf /var/mail/username/*? WARNING! ALL FILES AND FOLDERS IN FOLDER /VAR/MAIIL/USERNAME/ WILL BE PERMANENTLY DELETED

share|improve this answer
    
Thanks, but that doesn't seem to work. According to ls, "username" is a folder, rather a file... –  Greg Jun 21 '11 at 15:19
    
Er, what I said backwards. A mail file, not a folder. –  Greg Jun 21 '11 at 16:05
    
oh, I didn't know. –  kv1dr Jun 21 '11 at 17:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.