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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

keep 7 days of root mail

Status
Not open for further replies.

visvid

Technical User
Jun 3, 2002
131
GB
Monitor root mail in /var/spool/mail

I am trying to find a why of only keeping 7 days worth of root mail, I know you can delete mail within the mail programme with the d command, but I am trying to find a way I can place an entry into cron to run this as a weekly job.

As it’s a file –mtime does not work ( or I cant get it to work :) , anyone got any ideas ,

Cheers


Visvid

On the 7th day God created Super Moto
 
All the mail is stored in /var/spool/mail/userID, so you could just set a cron job up to remove or copy, then empty this file every Sunday.

mv /var/spool/mail/user1 /var/spool/mail/user1.old
cat /dev/null > /var/spool/mail/user1

Mike

"A foolproof method for sculpting an elephant: first, get a huge block of marble, then you chip away everything that doesn't look like an elephant."
 
Yes , but the idea is to find a way of keeping 7 days worth of users mail rather than moving or copying, currently we running with this concept you have mentioned. I am just trying to stream line it

Regards



On the 7th day God created Super Moto
:burnout:
 
The perl MailBox package looks like it could do what you want. I haven't worked with it, though (yet - I can think of some uses for it at home).

Just curious: Are you planning on deleting root mail unread? or just tired of "d"?

Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L

 
We do not have any other programmes for mail except the mail program , to reply to your Q its just a case of good house keeping with users mail with the 500 Unix sys we have. As most Unix systems root mail is never read by us

On the 7th day God created Super Moto
:burnout:
 
visvid,

Ignore this if I misunderstood your response. I'm assuming (dangerous) that your mentioning that you don't have any other programs for mail means you thought I was referring to one.

The MailBox I referred to isn't a program, it's a set of perl modules. With it, you can write a perl script to do what you want.

If you wrote perl scripts you would have understood that, of course, but I thought I'd clarify in case you have access to a perl programmer.

500 boxen. Does that mean you have, on average, more than one "once a year" type of problem each day? :)




Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L

 
Rod

Thanks for reply , you guessed right I am a not a perl programmer, to answer Q our department maintains all Unix systems for the Company , and part of our Admin is to check root and other userid mail as well as the errpt.

We do not look at ever box each day, but if our applications teams have problems we will log onto to these servers, over the last few days I have encountered lots of root mail, hence the idea of only keep 7 days ,

Hope that helps

On the 7th day God created Super Moto
:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top