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

cron job for mail in /var/spool/mail

Status
Not open for further replies.

visvid

Technical User
Jun 3, 2002
131
GB
Q:

var/spool/mail I want to set up a cron job that would look at the various mail files and keep only 4 weeks worth.

Anyone got any ideas or suggestions on this ?


Cheers


visivd
 
Code:
find /var/spool/mail -name XY -mtime +28 -exec rm {} \;

will find every file named XY (fix it to your needs) -modified time is at least(+) (4*7)*24 hours. These shall be removed.

Of course you should never simply execute a untested 'rm'-command and it is untested!

You know how to call it once per day with cron?

 
dont think this would work as the files in /var/spool/mail are updated when mail is sent to them, but something close

find /var/spool/mail -name root | xargs grep Mar
I can play with the xargs but cant get -mtime to work within this , but I have to change this parameter ever month

visvid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top