Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can we purge old messages from Unix mailbox?

Status
Not open for further replies.

Calator

Programmer
Feb 12, 2001
262
AU
We have a Unix mailbox that receives copies of automated generated email, for system administration purpose. No one would normally review this email, apart from Sys Admin in case of incidents.

We would like to automate the process of purging the mailbox of messages older than xxx days. Any ideas? Thanks.
 
I don't know that your question is a function of sendmail exactly. UNIX stores email in a certain folder for each user. Usually /var/spool/mail you will find a file for each user where all the incoming mail is stored. I don't know if just deleting this file every week would be sufficent for your needs.

You may try moving the file to a backup name so you have a way to get to older mail messages.

Does this help? Einstein47
("Vision without action is a daydream - Action without vision is a nightmare. Japanese Proverb")
 
Einstein47,
You're 100% right in all your statements, except for deleting the file will not exactly help, as this will delete the most recent messages as well. We think of deleting messages older than say 6 months. Short of us having to write a shell script to do that, are there any other ways (or has anyone already got such a script?). I realised this may not be a function of sendmail, but I thought this forum could be the best chance to find people that can answer this question. And thanks for the "vision".
 
You can accomplish your goals by treating the mail file like a log file. Either write a script to roll all the old files up one - mailfile.1 becomes mailfile.2, mailfile becomes mailfile.1 etc. deleting the last one - mailfile.180 or add the log rolling to syslog. If you write your own script have it run as a nightly cron job.
 
If you want to use the roll functionality that TheWiz2 mentioned, and you don't want to write something yourself, just ask - I wrote a nifty roll utility that could be useful. (can you tell I want to share, but I don't want to post it if it isn't used) Einstein47
("Vision without action is a daydream - Action without vision is a nightmare. Japanese Proverb")
 
Thank you guys, you both gave interesting food for thought. Yes, I would like to try out your file roll script. If you do not wish to post it in the forum, pls email to stefan.dan@nrgflinders.com.au
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top