-2

trying to figure out a cli way to empty all email from a specific email account.

It is certainly possible to type:

mutt -f account
D
~s .*
then quit....

Is there a way to do this all from cli/cron?

Tablemaker
  • 1,149
  • 1
  • 11
  • 23
CMag
  • 707
  • 2
  • 11
  • 32

2 Answers2

4

But echo -n > /var/spool/mail/account does the trick.

mailq
  • 17,023
  • 2
  • 37
  • 69
  • Make sure to do this as the user in question and not root or the file will end up with the wrong ownership. – Ladadadada Nov 22 '11 at 19:55
  • exactly why it would be nicer to bang this out via mutt, no? :) hence the mutt question, not a trick with echo/touch/etc :) – CMag Nov 22 '11 at 20:04
  • 2
    (+1) So you'd rather have Mutt analyze every mail header and "re-render" an empty mailfile using billions of CPU and Disk cycles? Do the echo. It doesn't matter who you do it as if the file already exists the permissions will not be changed. Also, just for cleanliness lets do `echo -n > /var/spool/mail/account` so it doesn't start with a newline. – Kyle Smith Nov 22 '11 at 20:30
  • You don't need the echo. `>/var/spool/mail/account` works and leaves a blank file rather than one with a linfeed in it. – user9517 Nov 22 '11 at 22:06
2

Would rm /var/spool/mail/account do the trick ?

Ladadadada
  • 26,337
  • 7
  • 59
  • 90