I want to clear the Linux mail for my account every day at 10pm. How can I accomplish it?

  • What part of the mail man page makes you think you can schedule things with mail? – Anthon Sep 27 '16 at 7:01
  • @Anthon I suspect if s/he knew that they wouldn't be asking – roaima Sep 27 '16 at 7:53

You could crontab -e to edit your personal list of cron jobs, and add the line:

0 22 * * * : > /var/mail/"$(whoami)"

which will, at 22:00 (10pm) every day, overwrite the file /var/mail/<your username> with empty data. If your mail file is stored somewhere else, you would need to change the path.

  • 1
    It's better to use : > /var/mail/"$(whoami)" as not all shells support empty redirection. – heemayl Sep 26 '16 at 21:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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