Operating System - HP-UX
1820195 Members
3956 Online
109620 Solutions
New Discussion юеВ

finding files older than 1 day

 
SOLVED
Go to solution
so.nimda
Super Advisor

finding files older than 1 day

Hi,

I've been trying to find files that are older than 1 day by using the "find -atime +1" command and so far, without any success.

This is what I get :

# ls -ltr
total 27632
-rw-rw---- 1 c11adm sapsys 7078850 Mar 14 22:27 TK20080314221511
-rw-rw---- 1 c11adm sapsys 7067957 Mar 15 22:27 TK20080315221512
# find . -atime +1 -exec ls -ltr {} \;
#
# date
Sun Mar 16 18:56:50 CDT 2008
# whoami
root
#

Based on the current date, I should have both files shown as older than i day.

Am I doing something wrong?

Thanks in advance.
9 REPLIES 9
Patrick Wallek
Honored Contributor

Re: finding files older than 1 day

Try '-mtime' instead.
James R. Ferguson
Acclaimed Contributor

Re: finding files older than 1 day

Hi:

# find /path -xdev -type f -mtime +1

...will find files that are older than 1-day based upon their last modication time ('mtime'). The '-type f' insures that you are returned only files and not directories, too. The '-xdev' keeps find() from crossing mountpoints. This is very useful when searching the root ('/') directory.

The '-atime' you used specifies the last access timestamp. The '-ctime' specifies the last time the file or directory's inode was changed --- a change in name, permissions, or ownership.

Regards!

...JRF...
so.nimda
Super Advisor

Re: finding files older than 1 day

Hi Patrick,

Thanks for the reply.

Just tried. Still not showing. In fact, I've also tried -ctime and it's also not showing.

The timestamp is on the file is the creation date and after that, I don't think it was ever accessed or modified.

Could that be the reason it's not retrieving as they were neither accessed or modified?

Regards


so.nimda
Super Advisor

Re: finding files older than 1 day

Hi James,

Thanks for the reply.

Just tried, no luck.

# ls -ltr
total 27632
-rw-rw---- 1 c11adm sapsys 7078850 Mar 14 22:27 TK20080314221511
-rw-rw---- 1 c11adm sapsys 7067957 Mar 15 22:27 TK20080315221512
#
# find . -xdev -type f -mtime +1
#

Yogeeraj_1
Honored Contributor

Re: finding files older than 1 day

hi,

..and what does the following command show:

find . -type f


also,
su adm
find . -xdev -type f -mtime +1


revert

kind regards
yogeeraj

No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Sajjad Sahir
Honored Contributor

Re: finding files older than 1 day

find then path -atime 1
for eg:find /usr/bin -atime 1
it will search files under /usr/sbin directory one day ago

find /etc -atime -7 it will search files accessed last 7 days
ok
Dennis Handly
Acclaimed Contributor

Re: finding files older than 1 day

After you finally figure out what's wrong, you should change the command to use "+" for performance:
# find . -atime +1 -exec ll -tr {} +
Tim Nelson
Honored Contributor
Solution

Re: finding files older than 1 day

FYI,

If you use the -atime option you can only do it once. the find command itself modifies the last access time.


-atime n True if the file access time subtracted from
the initialized time is n-1 to n multiples of
24 h. The initialization time shall be a
time between the invocation of the find
utility and the first access by that
invocation of the find utility to any file
specified by its path operands. ***** The access
time of directories in pathname_list is
changed by find itself.
so.nimda
Super Advisor

Re: finding files older than 1 day

hi all,

thanks for all your replies...

i think the -atime does indeed change the access timestamp...

regards