因此,我正在研究一个bash脚本来清除临时文件并遇到莫名其妙的行为。find - mtime vs mmin - 奇怪的结果
# Find using mmin flag
find /usr/local/store/file/temp/3_day/ -mmin +$((60*24*3)) -type f > /tmp/old_files_by_mmin.txt
# Find using mtime flag
find /usr/local/store/file/temp/3_day/ -mtime +3 -type f > /tmp/old_files_by_mtime.txt
diff -u /tmp/old_files_by_mmin.txt /tmp/old_files_by_mtime.txt
前几行:
--- /tmp/old_files_by_mmin.txt 2016-08-03 16:56:42.535458820 +0000
+++ /tmp/old_files_by_mtime.txt 2016-08-03 16:56:58.310681524 +0000
@@ -117,59 +117,6 @@
/usr/local/store/file/temp/3_day/image/resize/2016/07/29/11/15/36/1296924350
/usr/local/store/file/temp/3_day/image/resize/2016/07/29/11/47/52/1950191632
/usr/local/store/file/temp/3_day/image/resize/2016/07/29/11/30/01/711250694
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/10/04/15/44313759
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/10/04/15/1589177813
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/10/04/15/1189074525
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/10/56/44/91382315
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/09/43/45/1622776054
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/01/44/57/1465920226
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/01/23/17/1467026748
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/01/15/58/1990201487
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/01/13/19/1990298215
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/01/35/59/518813467
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/12/10/53/1962045410
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/12/31/27/290517373
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/12/05/08/547481306
为什么-mmin标志拿起文件的修改时间标志是不是?如果两者都应该找到比现在+ 3天更早的文件?
这可能与四舍五入的日子有关。顺便说一句,为什么'bash'?就我所知,“find”不是内置的。 – mustaccio
@mustaccio:我怀疑你是对的。不知道你的意思是不是“内置”。这是一个linux系统,所以bash/find总是可用的。 –
@MikePurcell,“内建”意味着“外壳的一部分”,而不是外部工具。如果它不是shell的一部分,那么你需要指定你的确切操作系统,以及你的操作系统提供哪个版本的工具。 –