Cron to delete files older than X days

Cameron Simpson cs at zip.com.au
Sun Apr 15 03:06:24 UTC 2012


On 12Apr2012 17:59, Facundo M. de la Cruz <fmdlc at code4life.com.ar> wrote:
| You can try with the -ctime option.
| 
| The syntax is ok, but if any process update the file content the mtime
| is updated too. The -ctime options seek for files which the metadata is
| not updapted for X amount of days.

But remember that ctime (last change to inode) is updated on chmod,
chown, file rename etc.

For debug purposes, put a -ls in the find ahead of the "-exec rm". That
way it will recite the file (and mtime) before removal.

And of course, if your cron job removed stuff, it will already be gone
when you come in to look later with your manual find.

Cheers,
-- 
Cameron Simpson <cs at zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

I took that Reading Dynamics course, and it really works.  I read _War and
Peace_ in an hour last night.  It's about Russia.       - W. Allen, ca. 1962




More information about the redhat-list mailing list