Operating System - HP-UX
1838681 Members
3701 Online
110128 Solutions
New Discussion

Possible problem with mtime switch to find

 
Marcel_3
New Member

Possible problem with mtime switch to find

I'm using find with the -mtime switch to delete directories containing old backup files.

The command looks like this:

find ${backup_dir} -type d -mtime 5 -exec rm -rf {} \;

This almost always works but sometimes it doesn't! For example, I have a directory with a date/time that appears to be 27-Jan-2001 in the ls -l listing but does not appear in a find -mtime 5.

Years ago I recall someting like this with IRIX but I was wondering if anyone could shed light on this with HP-UX 11
3 REPLIES 3
Dan Hetzel
Honored Contributor

Re: Possible problem with mtime switch to find

Hi Marcel

-mtime +5 will work for files having been modified in more than 5 days
-mtime -5 for les than 5 days
-mtime 5 for exactly 5 days

Best regards,

Dan
Everybody knows at least one thing worth sharing -- mailto:dan.hetzel@wildcroft.com
Rita C Workman
Honored Contributor

Re: Possible problem with mtime switch to find

The only difference I generally key is....
-mtime +5

Just a thought,
/rcw
James R. Ferguson
Acclaimed Contributor

Re: Possible problem with mtime switch to find

Marcel:

'mtime', 'atime' and 'ctime' operate on "up-to-the-minute" so your 5-day window should match a 24-hour one.

...JRF...