Operating System - HP-UX
1823914 Members
3389 Online
109667 Solutions
New Discussion юеВ

How do I find Files older than 4 hours in HP UX11.11

 
Nagu SR
Frequent Advisor

How do I find Files older than 4 hours in HP UX11.11

Hi,

I need the following requirement.

In a directory /tmp/test I need to find any files which are not accessed from the last 4 hours. I dont want to delete any files but need to know the Path of that file.

As per me, in HP find command there is no -mmin option like in LINUX. So - mtime/-atime/-ctime will tell me the days old. But not by time (Here 6 hours.

Could someone help me please???
8 REPLIES 8
Pete Randall
Outstanding Contributor

Re: How do I find Files older than 4 hours in HP UX11.11

Use touch to create a reference file with the desired timestamp, then use find's -newer option - or ! -newer.


Pete

Pete
Nagu SR
Frequent Advisor

Re: How do I find Files older than 4 hours in HP UX11.11

Hi,

Could you elaborate please....

In /tmp/test I need to find the files which are 4 hours old and need to know the path of the file. I dont want to change the time stamp of the file or I dont want to delete it also.

I just need those File names.(Path)
SANTOSH S. MHASKAR
Trusted Contributor

Re: How do I find Files older than 4 hours in HP UX11.11

Hi

Try this

# find /tmp/test ! -atime -4


Regards

-Santosh
Jeeshan
Honored Contributor

Re: How do I find Files older than 4 hours in HP UX11.11

you can use perl for find your requirement

#perl -MFile::Find -le 'find(sub{print $File::Find::name if -f $_ && -M _ <= 4/24},@ARGV)' /path
a warrior never quits
James R. Ferguson
Acclaimed Contributor

Re: How do I find Files older than 4 hours in HP UX11.11

Hi:

Since you are asking for the last *access* timestamp, the correct Perl solution is this:

# perl -MFile::Find -le 'find(sub{print $File::Find::name if -f $_ && -A _ >= 4/24},@ARGV)' /path

You can pass multiple '/path' arguments to the script, The age criteria is based on one day, so 4/24 of one day represents the desired 4-hours. The files returned by the above represent those whose access time equals or *exceeds* 4-hours. That is, they have *not* been recently accessed.

Thus Ahsan's copy-and-paste is incorrect.

Regards!

...JRF...
Steven Schweda
Honored Contributor

Re: How do I find Files older than 4 hours in HP UX11.11

> [...] in HP find command there is no -mmin
> option like in LINUX.

If you really like the "find" in GNU/Linux,
you could try (building and) using that
"find" on HP-UX. The source code is
available:

http://www.gnu.org/software/findutils/

By the way, "-mmin" is for the _modified_
date-time. "-amin" is for the _accessed_
date-time. You want which one?
Adam W.
Valued Contributor

Re: How do I find Files older than 4 hours in HP UX11.11

Nagu,

something like this could be useful


# touch -amt 200808181000 /tmp/ref1
# touch -amt 200808181400 /tmp/ref2

# find /opt/mtmc/ibs/import/reject -xdev -type f -newer /tmp/ref1 -a ! -newer /tmp/ref2 -exec rm {} \+

This will remove files that are newer (more recently modified) than 10:00AM AND NOT newer than 2:00 PM. Make sense? You can change the comand as needed to put the output into a file or directory or remove (as above).
There are two types of people in the world, Marines and those who wish they were.