How to find files by hours old?

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to find files by hours old?
# 1  
Old 03-12-2009
How to find files by hours old?

I need to be able to do the following:

Find files in multiple directories that are 6 hours older than the current time?
I am using KSH
I tried mmtime but it was not a valid option

Any help would be great. Thank you!
# 2  
Old 03-12-2009
Try mmin. In any case, check the manual on your system for find to see what options you have.

Also, if you're looking for files exactly six hours old, you may not find any. You may need to do -mmin +360 for files over six hours old, or -mmin -360 for files less than six hours old, depending on what you're trying to do.
# 3  
Old 03-12-2009
One way:
assume it is 8:00 am - you want files six hours old and younger
touch -t $(date +%Y%m%d0200) ./dummy1   # six hours ago
touch -t (date +%Y%m%d%H%S) ./dummy2    # now
find /path -type f  \( -newer ./dummy1 -a ! -newer ./dummy2 \)

You can change the touch date clause for any value range you need.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find hours difference between two dates in given format

I have two dates in below format, how would I find the hours difference between the two dates. Im using AIX and ksh. Current date : Wed May 17 14:34:41 SGT 2017 File date : Thu Apr 27 20:52:41 SGT 2017 (3 Replies)
Discussion started by: simpltyansh
3 Replies

2. UNIX for Dummies Questions & Answers

Find command to get the modified files past 2 hours

Hello, How to get the modified/created files past 2 hours in Solaris with find command? Thank you. (7 Replies)
Discussion started by: balareddy
7 Replies

3. UNIX for Dummies Questions & Answers

find the no of processes that ran 2 hours before or earlier

Is there a way to find out the total no of processes that were running ? - 2 or 3 hours before - list those no of processes (3 Replies)
Discussion started by: jansat
3 Replies

4. UNIX for Advanced & Expert Users

find files modified by hours instead of minutes

Is there an easy way to find files modified by hours? If you wanted to find something modified by like 28 hours then I know you could do this: find . -mmin -1440It is pain to break out a calculator and calculate in minutes. Could you do something similar to this? I know I don't have the right... (1 Reply)
Discussion started by: cokedude
1 Replies

5. Shell Programming and Scripting

files older than few hours

Hi All I need to know the command which can be used to list the files which are 3 hours old so that it can be deleted. (3 Replies)
Discussion started by: mskalyani9
3 Replies

6. Shell Programming and Scripting

Find files older than 8 hours

I need a script to find files older than 8 hours... I know i can use mmin but the same is not working...the same only support mtime... This is the script i created..but the same is only giving 1 hour I have given dt_H as 1 only...but if i give can go in -(negative) to get the... (5 Replies)
Discussion started by: cotton
5 Replies

7. Shell Programming and Scripting

how to list files between last 6 hours to 3 hours

Hi Frens, I want to list some files from a directory, which contains "DONE" in their name, i am receiving files every minute. In this i want to list all the files which are newer than 6 hours but older than 3 hours, of current time i dont want my list to contain the latest files which are ... (4 Replies)
Discussion started by: Prat007
4 Replies

8. AIX

how to find files older than 2 hours

I need help to find files in a directory that are older than 2 hours. Any help would be great. (3 Replies)
Discussion started by: pt14
3 Replies

9. Shell Programming and Scripting

unix command/s to find files older than 2 hours in a directory

I need to write a script to find files older than 2 hours in set of direcotries and list them ina mail. I know find command ti list files greater/lesser than days but i need to do it for hours. Any input. (6 Replies)
Discussion started by: Presanna
6 Replies

10. UNIX for Dummies Questions & Answers

find -mtime +2? means after 48 hours..

find /oracle/sydf/arch -mtime +2 -name 'sydf*' -type f -exec rm -f {} \; this means after 48 hours remove the files..... i am not sure about the command type f -exec rm -f {} \; does it means, check for files, then execute it .. then what doesw the {} and \ and ; means ? (1 Reply)
Discussion started by: yls177
1 Replies
Login or Register to Ask a Question

Featured Tech Videos