Tell me more ×
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

2 Answers

up vote 11 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

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

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.