1833056 Members
2619 Online
110049 Solutions
New Discussion

Re: find not working

 
SOLVED
Go to solution
jerry1
Super Advisor

find not working

When I do a "find . -mtime +1"
I get nothing. Yet there are files in the
current directory that older than 1 day.
Whats up with this?


18 14:06 BPC_1060630.log
-rw-rw-rw- 1 oracle cedwgs 9069 Nov 18 14:06 BPC_1060630.pdf
-rw-rw-rw- 1 oracle cedwgs 2685 Nov 18 16:22 BPC_1060636.log
-rw-rw-rw- 1 oracle cedwgs 38085 Nov 18 16:22 BPC_1060636.pdf
-rw-rw-rw- 1 oracle cedwgs 1775 Nov 18 16:25 BPC_1060643.log
-rw-rw-rw- 1 oracle cedwgs 200405 Nov 18 16:25 BPC_1060643.pdf
-rw-rw-rw- 1 oracle cedwgs 3980 Nov 18 16:29 BPC_1060649.log
-rw-rw-rw- 1 oracle cedwgs 1739266 Nov 18 16:29 BPC_1060649.pdf
-rw-rw-rw- 1 oracle cedwgs 1177 Nov 18 16:30 BPC_1060660.log
-rw-rw-rw- 1 oracle cedwgs 5592 Nov 18 16:30 BPC_1060660.pdf
-rw-rw-rw- 1 oracle cedwgs 1034 Nov 18 16:47 BPC_1060664.log
-rw-rw-rw- 1 oracle cedwgs 23257 Nov 18 16:47 BPC_1060664.pdf
-rw-rw-rw- 1 oracle cedwgs 1034 Nov 18 17:07 BPC_1060667.log
-rw-rw-rw- 1 oracle cedwgs 23257 Nov 18 17:07 BPC_1060667.pdf
-rw-rw-rw- 1 oracle cedwgs 1034 Nov 18 17:28 BPC_1060670.log
-rw-rw-rw- 1 oracle cedwgs 23257 Nov 18 17:28 BPC_1060670.pdf
-rw-rw-rw- 1 oracle cedwgs 1034 Nov 18 17:31 BPC_1060673.log
-rw-rw-rw- 1 oracle cedwgs 23257 Nov 18 17:31 BPC_1060673.pdf
.
.
.
.
10 REPLIES 10
Yang Qin_1
Honored Contributor
Solution

Re: find not working

Hi, here is an explanation for mtime value:

find . -mtime 0 # find files modified within the past 24 hours
find . -mtime -1 # find files modified within the past 24 hours
find . -mtime 1 # find files modified between 24 and 48 hours ago
find . -mtime +1 # find files modified more than 48 hours ago
find . -mmin +5 -mmin -10 # find files modifed between 5 and 10 minutes ago


Yang
A. Clay Stephenson
Acclaimed Contributor

Re: find not working

First, let's not overlook the obvious. Run the date command so that we know what the current time actually is as far as your box is concerned. Your command looks fine.
If it ain't broke, I can fix that.
jerry1
Super Advisor

Re: find not working

Please Clay. I am running ntpd.
If the time on these servers was not correct
to the second we would here about it from
production. Believe me. We have.
Besides. I cannot have files the have a time
stamp in the future if the time was two days
back.

.
.
.
rw-rw-rw- 1 oracle cedwgs 2091 Nov 20 10:37 BPC_1060908.log
-rw-rw-rw- 1 oracle cedwgs 98902 Nov 20 10:37 BPC_1060908.pdf
-rw-rw-rw- 1 oracle cedwgs 2716 Nov 20 10:46 BPC_1060915.log
-rw-rw-rw- 1 oracle cedwgs 135976 Nov 20 10:46 BPC_1060915.pdf
-rw-rw-rw- 1 oracle cedwgs 2380 Nov 20 10:53 BPC_1060925.log
-rw-rw-rw- 1 oracle cedwgs 5487 Nov 20 10:53 BPC_1060925.pdf
-rw-rw-rw- 1 oracle cedwgs 2632 Nov 20 11:01 BPC_1060933.log
-rw-rw-rw- 1 oracle cedwgs 5487 Nov 20 11:01 BPC_1060933.pdf
-rw-rw-rw- 1 oracle cedwgs 1067 Nov 20 12:58 BPC_1060942.log
-rw-rw-rw- 1 oracle cedwgs 3751 Nov 20 14:02 BPC_1060945.log
-rw-rw-rw- 1 oracle cedwgs 11924 Nov 20 14:02 BPC_1060945.pdf
-rw-rw-rw- 1 oracle cedwgs 3751 Nov 20 14:03 BPC_1060957.log
-rw-rw-rw- 1 oracle cedwgs 11924 Nov 20 14:03 BPC_1060957.pdf
-rw-rw-rw- 1 oracle cedwgs 3841 Nov 20 14:06 BPC_1060969.log
-rw-rw-rw- 1 oracle cedwgs 5990 Nov 20 14:06 BPC_1060969.pdf
-rw-rw-rw- 1 oracle cedwgs 10727 Nov 20 14:59 BPC_1060981.log
-rw-rw-rw- 1 oracle cedwgs 1907 Nov 20 15:16 BPC_1060993.log
-rw-rw-rw- 1 oracle cedwgs 1177 Nov 20 15:16 BPC_1060997.log
-rw-rw-rw- 1 oracle cedwgs 5688 Nov 20 15:16 BPC_1060997.pdf
-rw-rw-rw- 1 oracle cedwgs 1177 Nov 20 15:17 BPC_1061001.log
-rw-rw-rw- 1 oracle cedwgs 6522 Nov 20 15:17 BPC_1061001.pdf

Sonny Chee
Advisor

Re: find not working

You might want to try

find . -ctime +1 (changee more than 1 day ago)
or
find . -atime +1 (accessed more then 1 day ago)


Sonny
Life is too short to spent on solving Unix problems, ask the forum experts.
A. Clay Stephenson
Acclaimed Contributor

Re: find not working

The datestamps on the files mean absolutely nothing about current time as I could easily create a file with a datestamp 10 years into the future (or past); that's why I wanted a date output. In any event, if your ls -l and your find . command are running from the same current working directory as the same user then find should be working. You might try installing the find cumulative patch (e.g. PHCO_34241 for 11.11) but I'm skeptical. There is something not quite right here (possibly missing search permission on the directory as this user?) You might also humor me and use an absolute path rather than "." in the find command.
If it ain't broke, I can fix that.
TwoProc
Honored Contributor

Re: find not working

If you run that original find command after 2:00 PM today, I think your files will show up. That's over your 48 hour break point.
We are the people our parents warned us about --Jimmy Buffett
Yang Qin_1
Honored Contributor

Re: find not working

Hi, Jerry, try "find . -mtime +1|xargs ls -ltr" in /tmp or a dir where you have lots of files created everyday. You will see that it will find files modified more than 48 hours ago but not 24 hours ago.

If you want to find files between 24 and 48 hours use "find . -mtime 1"

Yang
jerry1
Super Advisor

Re: find not working

DUGH!! Sometime you have a bad day(s).

Thanks Yang.


Yang, what is the option "mmin" in
"find . -mmin +5 -mmin -10 "

mmin?
Sandman!
Honored Contributor

Re: find not working

Hi Jerry,

The -mtime reports files that have changed between the argument to mtime and the time the files are accessed by find. Basically I'm reiterating what has already been said by Clay i.e. to post the current date and time on your server since the diff between that and the file mtime as reported by ls will determine whether the files will show up or not.

~cheers
Yang Qin_1
Honored Contributor

Re: find not working

Hi, Jerry, mmin (modified in minutes) is not available on HPUX. I'm sorry to mention that example.


Yang