How to find the files that are created in the last hour in unix

UnixFind

Unix Problem Overview


How to find the files that are created in the last hour in unix

Unix Solutions


Solution 1 - Unix

If the dir to search is srch_dir then either

$ find srch_dir -cmin -60 # change time

or

$ find srch_dir -mmin -60 # modification time

or

$ find srch_dir -amin -60 # access time

shows files created, modified or accessed in the last hour.

correction :ctime is for change node time (unsure though, please correct me )

Solution 2 - Unix

UNIX filesystems (generally) don't store creation times. Instead, there are only access time, (data) modification time, and (inode) change time.

That being said, find has -atime -mtime -ctime predicates:

$ man 1 http://pubs.opengroup.org/onlinepubs/009695399/utilities/find.html">find</a>
...
-ctime  n
The primary shall evaluate as true if the time of last change of
file status information subtracted from the initialization time,
divided by 86400 (with any remainder discarded), is n.
...

Thus find -ctime 0 finds everything for which the inode has changed (e.g. includes file creation, but also counts link count and permissions and filesize change) less than an hour ago.

Solution 3 - Unix

check out this link and then help yourself out.

the basic code is

#create a temp. file
echo "hi " >  t.tmp
# set the file time to 2 hours ago
touch -t 200405121120  t.tmp 
# then check for files
find /admin//dump -type f  -newer t.tmp -print -exec ls -lt {} \; | pg

Solution 4 - Unix

find ./ -cTime -1 -type f

OR

find ./ -cmin -60 -type f

Solution 5 - Unix

sudo find / -Bmin 60

From the man page:

> -Bmin n > > True if the difference between the time of a file's inode creation and > the time find was started, rounded up to the next full minute, is n > minutes.

Obviously, you may want to set up a bit differently, but this primary seems the best solution for searching for any file created in the last N minutes.

Solution 6 - Unix

Check out this link for more details.

To find files which are created in last one hour in current directory, you can use -amin

find . -amin -60 -type f

This will find files which are created with in last 1 hour.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAnkurView Question on Stackoverflow
Solution 1 - UnixsameerView Answer on Stackoverflow
Solution 2 - UnixephemientView Answer on Stackoverflow
Solution 3 - UnixayushView Answer on Stackoverflow
Solution 4 - Unixgwecho huangView Answer on Stackoverflow
Solution 5 - Unixsudon'tView Answer on Stackoverflow
Solution 6 - UnixJamre LudhiView Answer on Stackoverflow