[Linux-aus] Automate old file deletion, help!

Les Bell lesbell at lesbell.com.au
Mon Mar 10 06:04:02 UTC 2003


Tom Swann <tom.swann at jcu.edu.au> wrote:

>>
I would like to delete any file which has not been accessed for two weeks,
and
run the process once a week at a set time eg 0400 Sunday morning.
<<

What you want here is the find command, and specifically its -atime option.
For example:

find /usr/attachments -atime +14 -exec rm {} \;

And then either:

put a line like

00  04  *  *  0 root /usr/local/clean-attachments

into /etc/crontab, or:

create a file containing the find command in /etc/cron.weekly and call it
10clean-attachments.

I'll leave you to experiment with this. . .  <g>

Best,

--- Les Bell, CISSP
[http://www.lesbell.com.au]





More information about the linux-aus mailing list