Some automatic processes, like those made at regular times using cron, generate a lot of messages. I would like to delete automatically those older than a month so my mailbox doesn't grow too much.
I tried with a bash script that archives the old messages and tries to delete them from the mailbox, but I get this message from the system:
Mailbox /var/spool/mail/username was modified or is in use now.
It's not safe to complete the operation...
I have the same problem with both exim and postfix (in different servers).
I guess I could do it simulating a local email client like mutt using bash or python but I am not sure how to do it. I am not interested in using maildir because there are thousands of small messages that are more manageable in a single mailbox.
This is a local server using mail spool and local clients. We are not using imap or sending messages outside the server.
I will appreciate any hints.