Contents
How do I delete old emails in Linux?
8 Answers. You can simply delete the /var/mail/username file to delete all emails for a specific user. Also, emails that are outgoing but have not yet been sent will be stored in /var/spool/mqueue . -N Inhibits the initial display of message headers when reading mail or editing a mail folder.
How do I delete a specific date in Linux?
How to delete all files before a certain date in Linux
- find – the command that finds the files.
- . –
- -type f – this means only files.
- -mtime +XXX – replace XXX with the number of days you want to go back.
- -maxdepth 1 – this means it will not go into sub folders of the working directory.
What is in var spool mail?
Answer. Files in /var/spool/mail are flat text files that serve as the user’s mailbox. You can just move them out of the way or zero them out, if you are sure that the mails are not needed by the user.
How to delete all emails in a Linux mail box?
You can simply delete the /var/mail/username file to delete all emails for a specific user. Also, emails that are outgoing but have not yet been sent will be stored in /var/spool/mqueue.
How to delete all files before a certain date in Linux?
If you have a list of files, but you only want to delete files older the a certain date, for example, a maildir folder with 5 years worth of email, and you want to delete everything older then 2 years, then run the following command. find. -type f -mtime +XXX -maxdepth 1 -exec rm {} ; The syntax of this is as follows.
What’s the best way to delete a range of emails?
You can delete a range of messages with a command like d 1-42 (delete the first 42 messages). If you want more control, I recommend Mutt, a command line email client that gives you a lot more control than the mail command.
Are there different ways to delete emails in POSIX?
There are many different mail commands out there with different command sets. POSIX standardizes a mailx command. Your mailbox will typically contain emails in the order in which they were received. So to delete older mails, you would typically delete lower-numbered emails.