I have a strange issue with a cron-scheduled task using find which does two things:
- The first line should delete every night files older than 3 days starting with "read_" and end with ".gz".
- The second line should delete every minute files ending with ".gz.md5" older than 1 minute.
1 1 * * * find <path that defiantly does not match> -type f -iname "read_*.gz" -ctime +3 -delete
*/1 * * * * find <path that defiantly does not match> -type f -iname "*.gz.md5" -cmin +1 -delete
Typically this is working well, but every now and then at 01:01 I get the following error message by cron:
Cron <root@hostname> find <path that defiantly does not match> -type f -iname "read_*.gz" -mtime +3 -delete
find: ‘<path that defiantly does not match>/<hostname>/captured-syslog-1617836127-1617836351.gz.md5’: No such file or directory
But from my point of view, this makes no sense.
logrotateor similar) running too, that may rotate thecaptured-syslog-*files at 01:00? – Kusalananda Apr 08 '21 at 07:13logrotatejob running at 01:00 which manages thecaptured-syslog-*files? – Kusalananda Apr 08 '21 at 07:1601:01AM? do you confirm that gz.md5 files deletion can finish in 1minute? if not then at next running time you will get that error as those are still under deletion by previous attempt by the cronjob and at the same time second attempt found them by when trying to delete they already deleted by previous same job – αғsнιη Apr 08 '21 at 08:28ctimeis NOT create time. It's inode change time. Usemtimeinstead – Chris Davies Apr 08 '21 at 08:30<path that defiantly does not match>, is this path contains both.gz.md5andread_*.gzfiles? if so then the error is come from because of these as both find comnad sees all the files in that path before passing to iname filter, so no worry about this prompt – αғsнιη Apr 08 '21 at 09:33ctimerefers to, then that's great. Many people mistakectimefor creation time and I was concerned that this group might have included you. – Chris Davies Apr 08 '21 at 09:45