Pretty wierd error message came up on Centos.

I tried to run this command:

find /tmp/something -type f -mtime +2h -exec cp '{}' /tmp/target \;

And the error I've got:

find: invalid argument `-exec' to `-mtime'

Can the 'find' be different on other distributions?

2 Answers 2


-mtime is used for days, if you need 2 hours check this:

find /tmp/something -type f -mmin +120 -exec cp '{}' /tmp/target \;

mmin specifies minutes so -mmin +120 will filter those more than 120 minutes ago (2 hours). From the manual:

-mtime n

File's data was last modified n*24 hours ago. See the comments for -atime to understand how rounding affects the interpretation of file modification times.

-mmin n

File's data was last modified n minutes ago.


the find implementation on MacOS is a little bit different than the one available on Linux. I believe you got the error above on a Linux system.

On Linux, mtime only accepts +- and a number. The number is the number of days.

For what you want to do above you have to use mmin

-mmin n
      File’s data was last modified n minutes ago.

This command should work on Linux:

find /tmp/something -type f -mmin +120 -exec cp '{}' /tmp/target \;
  • Yes, you're right, it was a Mac vs CentOS issue. Thanks!
    – t.fazakas
    Jun 8, 2015 at 13:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .