Files older than 1 day not deleted with –mtime +1
I have set a cron job which is something like:
find <path> -iname '*.dmp' -mtime +1 -exec rm -vf {} \; This job ran at 10 am (17th July) today but did not delete files which were created on 16th July around 2 am though it is more than 24 hours. I hope I have been able to explain the query that why files older than 1 day are not being picked up. Requesting a reply to my query. Regards |
Hi,
Are you sure the job ran? If so, do you have a log of it's output? It might be in your email on that machine if you didn't explicitly redirect it somewhere. Can you confirm that the "find" is finding all the files, by running: Code:
find <path> -iname '*.dmp' -mtime +1 -ls Regards, Clifford |
Thanks for your answer. According to my finding,
find <path> -iname '*.dmp' -mtime +0 -ls is finding the required files accessed more than 24 hours ago but not +1. Non-root user is running the command. There is no issue of file permissions. Should it be find <path> -iname '*.dmp' -mtime +0 -ls then? Regards |
I guess you can be forgiven for not digging through the rather lengthy find manpage, but the answer is there.
-atime nSo yes, you would need to use "+0".File was last accessed n*24 hours ago. When find figures out how many 24-hour periods ago the file was last accessed, any fractional part is ignored, so to match -atime +1, a file has to have been accessed at least two days ago.-mtime nFile’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. |
Hi again,
You mention files accessed more than 24 hours ago. Are you interested in access time, or modification time ("mtime")? The "+1" is the correct usage, and should work (assuming mtime is what you want to check). Could you possibly run the "stat" command for one of these files, and post the output? |
Quote:
|
RHCE_ran, if you're looking for files older than 24 hours exactly (which is what I though "-mtime +1" does), as opposed to files modified before yesterday, try:
Code:
find <path> -iname '*.dmp' -mmin +1440 -ls |
All times are GMT -5. The time now is 01:19 PM. |