linux上没有这样的文件或目录查找命令 [英] No such file or directory find command on linux
问题描述
我创建了从目录中删除旧备份文件的脚本,但此命令在 1 周前运行良好,脚本或软件包没有任何变化,但仍然出现以下错误:
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
问题是,这个脚本每天都在 cron 上运行,我收到类似find: `/var/backups/abc/2016-03-08_0321': No such file or directory"的邮件.文件被删除,但这样的邮件是从 root 获取的.
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.
推荐答案
find /var/backups/abc/* -type d -mtime +6 -prune -exec rm -rf {} ;
在这里,我们在要删除的目录上使用 -prune
,因此 find
将不会尝试读取它们的内容.
Here, we use -prune
on the directories that we're about to delete, so find
will then not try to read their contents.
这篇关于linux上没有这样的文件或目录查找命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!