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

前端 未结 6 1123
栀梦
栀梦 2021-01-29 18:36

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

相关标签:
6条回答
  • 2021-01-29 19:06

    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.

    0 讨论(0)
  • 2021-01-29 19:13

    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 )

    0 讨论(0)
  • 2021-01-29 19:15

    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 find
    ...
    -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.

    0 讨论(0)
  • 2021-01-29 19:21
    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.

    0 讨论(0)
  • 2021-01-29 19:28

    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
    
    0 讨论(0)
  • 2021-01-29 19:31

    find ./ -cTime -1 -type f

    OR

    find ./ -cmin -60 -type f

    0 讨论(0)
提交回复
热议问题