问题
I've created script which delete old backup file from directory but this command was worked fine before 1 week and Nothing change on script or packages but still getting below error:
root@:# find /var/backups/abc/* -type d -mtime +6
/var/backups/abc/2016-03-09_0321
root@:~# find /var/backups/abc/* -type d -mtime +6 -exec rm -rf {} \;
find: `/var/backups/abc/2016-03-08_0321': No such file or directory
Problem is that, this script run every day on cron, I getting a mail like " find: `/var/backups/abc/2016-03-08_0321': No such file or directory". files are deleted but such a mails are getting from root.
回答1:
find /var/backups/abc/* -type d -mtime +6 -prune -exec rm -rf {} \;
Here, we use -prune
on the directories that we're about to delete, so find
will then not try to read their contents.
回答2:
This is because of after having returned your directory, find will try to look in it (to continue his recursive search), and will fail because of you just removed it.
来源:https://stackoverflow.com/questions/36003434/no-such-file-or-directory-find-command-on-linux