Hi all,
It looks like find command treats -mtime +2 as more than 2 days not more
than 2 24 hour periods. (note: sun was the same, but AIX was different) I
ended up creating a shell script to do the 2 day comparison. I will send
it to anyone who is interested.
The unix open group (www.opengroup.org formaly osf) defines it as:
"The descriptions of -atime, -ctime and -mtime use the terminology n "
24-hour periods". For example, a file accessed at 23:59 will be
selected by:
find . -atime -1 -print
at 00:01 the next day (less than 24 hours later, not more than one day
ago);
the midnight boundary between days has no effect on the 24-hour
calculation. "
Thanks to: (full replies are below)
Dr. Thomas P. Blinn, UNIX Software Group, Digital Equipment Corporation
Larry Griffith Dept. of Computer & Info Science
- Jerry Berkman, UC Berkeley
Mark Greenhalgh
IDX Systems Corporation
> -----Original Message-----
> Hi all,
>
> I'm trying to use the find command to remove old file and the
> -mtime
> option is either busted or I'm just not using it right.
>
> # date
> Thu Jan 22 16:10:42 EST 1998
> # ls -lc
> total 298336
> -rw-r--r-- 1 root dba 9990307 Jan 19 20:18
> train-19-Jan-98_2000.DMPZ
> -rw-r--r-- 1 root dba 10009825 Jan 20 20:25
> train-20-Jan-98_2000.DMPZ
> -rw-r--r-- 1 root dba 92329673 Jan 21 20:16
> vantive-21-Jan-98_2000.DZ
> # ls -l
> total 298336
> -rw-r--r-- 1 root dba 9990307 Jan 19 20:18
> train-19-Jan-98_2000.DMPZ
> -rw-r--r-- 1 root dba 10009825 Jan 20 20:25
> vantive-20-Jan-98_2000.DZ
> -rw-r--r-- 1 root dba 92329673 Jan 21 20:13
> vantive-21-Jan-98_2000.DZ
> #
> #
> # find ./ -name \* -mtime +2 -exec ls -lc {} \;
>
> Doesn't find any files even though from the above directory listing
> the it
> should at least find the Jan-19 files ? Shouldn't it ? The way I'm
> reading
> it is any files that were last modified more than 2 days ago. If today
> is
> the 22nd than 2 days ago would be the 20th ?
>
> #
> #
> # find ./ -name \* -mtime +1 -exec ls -lc {} \;
> -rw-r--r-- 1 root dba 91144493 Jan 19 20:16
> ./vantive-19-Jan-98_2000Z
> -rw-r--r-- 1 root dba 9990307 Jan 19 20:18
> ./train-19-Jan-98_2000.DMZ
> #
>
>
>
> Thanks
> Mark Greenhalgh
> IDX Systems Corporation
> mark_greenhalgh_at_idx.com
>
---------------------- Forwarded by Mark Greenhalgh/BOSTON/IDX1 on 01/23/98
03:35 PM ---------------------------
Probably depends on the time of day that you do the command. I believe
that
the interpretation of -mtime +2 is going to be "at least 48 hours before
the
current time". And I'm not certain that XPG4 means it's interpreted as "at
least 72 hours", but that doesn't make a lot of logical sense. In any
case,
it's really based on the hours in a day, not on a simple date compare, so
it
is sensitive to the time of day when you run the command compared to the
time of day when the files were modified.
Tom
Dr. Thomas P. Blinn, UNIX Software Group, Digital Equipment Corporation
110 Spit Brook Road, MS ZKO3-2/U20 Nashua, New Hampshire 03062-2698
Technology Partnership Engineering Phone: (603) 884-0646
Internet: tpb_at_zk3.dec.com Digital's Easynet: alpha::tpb
ACM Member: tpblinn_at_acm.org PC_at_Home: tom_at_felines.mv.net
Worry kills more people than work because more people worry than work.
Keep your stick on the ice. -- Steve Smith ("Red Green")
My favorite palindrome is: Satan, oscillate my metallic sonatas.
-- Phil Agre, pagre_at_ucsd.edu
Opinions expressed herein are my own, and do not necessarily represent
those of my employer or anyone else, living or dead, real or imagined.
---------------------- Forwarded by Mark Greenhalgh/BOSTON/IDX1 on 01/23/98
03:35 PM ---------------------------
Dear Mark,
Believe it or not, more than 2 days means at least 3 FULL days!
If it's 2 days, 23 hours, and 59 minutes old, find ... -mtime +2 won't
find it!
Larry
===========================================================================
=
Larry Griffith Dept. of Computer & Info Science
larry_at_garfield.wsc.mass.edu Westfield State College
(413) 572-5294 Westfield, MA 01086 USA
PGP public key available at:
http://garfield.wsc.mass.edu/dcis/griffith.html
===========================================================================
=
---------------------- Forwarded by Mark Greenhalgh/BOSTON/IDX1 on 01/23/98
03:35 PM ---------------------------
It looks like it interprets +2 as more than 2 days, as in 3 days or more,
rather than more than 2*24 hours. I'm surprised, but that seems to be
the case. Try -mtime 2, -mtime +2, and -mtime -2, and see how it
categorizes
all the files. Also, your find could be expressed simpler as:
find . -mtime +1 -exec ls -lc {} \;
your don't need the -name or / after the period.
- Jerry Berkman, UC Berkeley
Received on Fri Jan 23 1998 - 21:55:08 NZDT