I'm trying to delete the files that are 5 days old..
Clearly the modified date is April 15 for workorders.sql
My code won't delete it. However if I use +4 then it will delete it. Am I missing something?
Please specify your operating system details along with your shell.
mtime - modified time- time the file has been written / deleted from, displayed as Modify: ... using stat command against file.
ctime - creation time - time the file was created, displayed as Birth: .. using stat command against file (if maintained)
atime - access time - time the file was accessed, displayed as Access: .. using stat command against file (if maintained)
So trying those switches without understanding them, can delete a lot of stuff you probably do not want.
+4 is correct format, since +0 is 24 hours from the time find was executed.
user@host:~/files/sql$ date
Wed 22 Apr 2020 06:38:58 AM CEST
user@host:~/files/sql$ ls -lrt
total 0
-rw-r--r-- 1 user user 0 Apr 17 16:00 workorders.sql
-rw-r--r-- 1 user user 0 Apr 22 06:18 wmweb_test.sql.gz
user@host:~/files/sql$ find /path/to/files/sql -type f -name "*.sql" -mtime +4 # nothing found, why ?
Lets look at the manual for -atime as it explains the rounding which happens on all time options :
Ok this makes is more clear, but how can i find what i want using GNU find ?
If you are not using GNU find or need greater resolution from / to, that can be achived using touch with temporary files, and using -newer and ! -newer with find .
Forum is full of those examples, so use a search option please.