I would like a Linux command to find files changed in the last n seconds.

Is there a shell script or other tool that I can run from command line interface or GUI?

7 Answers 7


The solution with mtime specifying seconds doesn't work on my linux systems that use find --version == find (GNU findutils) 4.4.2.

I get the following error:

mycomputer:~/new$ find . -mtime -60s
find: missing argument to `-mtime'
mycomputer:~/new$ find . -mtime -60seconds
find: missing argument to `-mtime'

However, I can use -mmin (for modified in the last m minutes), and can it can take in a decimal argument; e.g., the following finds files modified in the last 30 seconds.

find . -mmin 0.5

So for example; creating files last modified 1s, 6s, 11s, ... ago for the past 120 seconds, this command finds:

mycomputer:~/new$ for i in $(seq 1 5 120); do touch -d "-$i seconds" last_modified_${i}_seconds_ago ; done
mycomputer:~/new$ find . -mmin 0.5

So if you really need it in seconds you can do something like:

localhost:~/new$ for i in $(seq 1 1 120); do touch -d "-$i seconds" last_modified_${i}_seconds_ago ; done
localhost:~/new$ N=18; find . -mmin $(echo "$N/60"|bc -l)

Use find command like this:

find . -name "*.txt" -mtime -60s

To find all *.txt files modified in last 60 seconds.

  • 18
    In linux, using find (from GNU findutils 4.4.2), I get an error with this command: find: missing argument to `-mtime'. However, I can get the desired behavior using -mmin and a decimal argument. I could not find any reference in the manpage for find for using s as an argument.
    – dr jimbob
    Jun 4, 2013 at 15:59
  • 9
    -60s isn't a valid argument to -mtime. Nor is "60s" even a valid option in POSIX or GNU find. The argument to -mtime is a number which specifies the number of 24-hour periods ago when a file was modified.
    – dannysauer
    Nov 4, 2014 at 16:57

The simplest way to do this is:

find . -name "*.txt" -newermt '6 seconds ago'

The -mtime -60s option, mentioned in an answer, doesn't work on many versions of find, even in 2016. -newermt is a much better option to us. It can parse many different date and time formats.

An alternative method using mmin is this:

find . -name "*.txt" -mmin -0.5

# Finds files modified within the last 0.5 minute, i.e. last 30 seconds

This option might not work for all find versions.

  • 3
    This is clearly the best solution.
    – rednoah
    Feb 3, 2017 at 14:06

Similar to what glenn suggested, if you want to find everything modified, say, in the time during which an installer process was running, it might be easier to do something like:

touch /tmp/checkpoint
<do installer stuff>
find / -newer /tmp/checkpoint

Then you don't have to do the time calculation; you just find things changed after the checkpoint file.


If you have a version of find that doesn't support -mtime -60s then a better solution is

touch -d '-60 seconds' /tmp/newerthan
find . -name "*.txt" -newer /tmp/newerthan

If you're monitoring a directory for changes to files, you probably want to use inotify-tools instead of some infinite polling loop.


If your version of find does not accept seconds or real values, just like mine, use -mmin, but specify 0, and you'll get all files modified in less than a minute:

$ touch test; find . -type f -mmin 0

You must log in to answer this question.