I was trying to use find
with -mtime +1
to find all directories older than 24 hours but having issues getting this done. I understand that using -mtime +n
should remove n*24 hours of data but it seems to only find one folder to remove - 2019-07-05
. Why doesn't it also offer the 2019-07-06
folder?
From find
man page:
-mtime n
File's data was last modified n*24 hours ago.
Example:
[user@craptaindee mysql] find /some/folder/mysql/ -type d -mtime +1
/some/folder/mysql/2019-07-05
[user@craptaindee mysql] find /some/folder/mysql/ -type d
/some/folder/mysql/
/some/folder/mysql/2019-07-07
/some/folder/mysql/2019-07-06
/some/folder/mysql/2019-07-08
/some/folder/mysql/2019-07-05
Here are the timestamps on the folders
drwxr-xr-x 2 root root 4096 Jul 5 23:40 2019-07-05
drwxr-xr-x 2 root root 4096 Jul 6 23:40 2019-07-06
drwxr-xr-x 2 root root 4096 Jul 7 23:40 2019-07-07
drwxr-xr-x 2 root root 4096 Jul 8 13:00 2019-07-08
I was able to complete my task using -mmin
but I don't understand why -mtime
doesn't act as I would expect from the man
page. Also, -ctime
doesn't show the other directory either.
EDIT: I completed these tests just before making this post in the early afternoon in the Pacific Timezone at roughly ~13:00 on July 08 2019.
2019-07-06
doesn't qualify because of its later hour. – Kamil Maciorowski Jul 09 '19 at 18:03+0
instead of+1
. Thanks @Kancer – saleetzo Jul 09 '19 at 18:22