Operating System - HP-UX
1837097 Members
2377 Online
110112 Solutions
New Discussion

Find files older than certain timestamp

 
Maarten van Maanen
Regular Advisor

Find files older than certain timestamp

I'm using a script to find Oracle ARC-files to delete after they have been backed up on tape. For this, I use the find -mtime command. However, this only gives met 24-hour periods.
Is there a way to find/list files with file-dates with a specific date/time-stamp.
For example, find files older than 22-08-2000 18:00 hours.
This, of course, to be used in a script to mv, zip or delete these specific files.
5 REPLIES 5
Alex Glennie
Honored Contributor

Re: Find files older than certain timestamp

Try a search using find timestamp, lots of artilcles but there's one create script to purge files except latest 100 ... that may prove very useful ?
Manuel Plaza
Regular Advisor

Re: Find files older than certain timestamp

Hi,
To begin with, excuse me for my english.
A simple way is to use other file how reference for time.
For example if you have the following file:
Aug 22 18:00 example_file
you can find and remove files older than example_file with:

find . ! -newer example_file -exec rm {} ;

Regards,
CHRIS_ANORUO
Honored Contributor

Re: Find files older than certain timestamp

Use find / -mtime +(# of days) -ok rm -i {} \;

Check a previous solution : http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x194b49c5ae73d4118fef0090279cd0f9,00.html
When We Seek To Discover The Best In Others, We Somehow Bring Out The Best In Ourselves.
RikTytgat
Honored Contributor

Re: Find files older than certain timestamp

Hi,

I suppose you could use a combination of find -newer , ls and touch.

1. Use touch to create a file w/ timestamp you need (touch -t 200008231200 reffile)
2. Create a list (list1) of all files newer than that time using find . -newer reffile
3. Create a list (list2) of all files using find . -print
4. Do whatever you want with the files in list2 that are not in list1.

Bye,
Rik
RikTytgat
Honored Contributor

Re: Find files older than certain timestamp

Hi,

Manuel's solution is of course much better than mine!!!

Bye,
Rik.