我破坏了 Ubuntu 的 FIND 命令,mtime 没有正常工作

I broke the FIND command of Ubuntu, mtime not working as it should

我正在构建一个备份脚本,并且大量使用带有 -mtime 的 FIND。 昨天我经常使用 find -mtime +1 来搜索超过一天前修改的文件。 一天结束的时候,我用了一整天的命令停止工作了。

user@ubuntu-4:~$ mkdir test
user@ubuntu-4:~$ cd test/
user@ubuntu-4:~/test$ touch -t 201601180830 yesterdayMorning
user@ubuntu-4:~/test$ touch -t 201601181725 yesterdayAfternoon
user@ubuntu-4:~/test$ ll
total 32
drwxrwxr-x 2 user user  4096 Jan 19 09:37 ./
drwx------ 9 user user 12288 Jan 19 09:36 ../
-rw-rw-r-- 1 user user     0 Jan 18 17:25 yesterdayAfternoon
-rw-rw-r-- 1 user user     0 Jan 18 08:30 yesterdayMorning

FIND -mtime n的结果

user@ubuntu-4:~/test$ find -mtime +1
user@ubuntu-4:~/test$ find -mtime -1
.
./yesterdayAfternoon
user@ubuntu-4:~/test$ find -mtime 0
.
./yesterdayAfternoon
user@ubuntu-4:~/test$ 

我应该能够找到名为 yesterdayMorning 的文件,因为在我撰写本文时(1 月 19 日上午 09:48)该文件已存在超过 1 天。

find -mtime -1(或 0 也是)显示正确的结果,因为文件的最后修改时间少于 24 小时。

昨天下午 5 点之前,我发誓它在工作!

其实不是24小时前,而是n天前。 IE。对于-mtime +1,它必须在两天前修改。

使用 find -mtime +0 也可以匹配昨天的文件。

如已接受的答案所述,-mtime +0 在这种情况下对您有用。 注:

find using -mtime and -daystart
-mtime n 
    File's data was last modified n*24 hours ago.
-daystart 
    Measure  times  (for  -amin,  -atime,  -cmin, -ctime, -mmin, and
    -mtime) from the beginning of today rather than  from  24  hours
    ago.
    This  option only affects tests which appear later on the
    command line.

date
Tue Jan 19 10:24:43 CET 2016
~/test $ ls -n
total 0
-rw-r--r-- 1 1000 1000 0 Jan 18 10:15 yesterdayMorning10:15.txt
-rw-r--r-- 1 1000 1000 0 Jan 18 10:45 yesterdayMorning10:45.txt
~/test $ find -mtime +0
./yesterdayMorning10:15.txt

~/test $ find -mtime 0
./yesterdayMorning10:45.txt

~/test $ find -daystart -mtime +0
./yesterdayMorning10:15.txt
./yesterdayMorning10:45.txt