我的要求与这个问题差不多:Shell脚本删除n天前的目录 我的目录看起来像这样:
Jul 24 05:46 2013_07_24
Jul 31 22:30 2013_08_01
Sep 18 05:43 2013_09_18
Oct 07 08:41 2013_10_07
我想删除90天前的所有内容。根据上述线程中提供的解决方案,我在我的脚本中使用了以下内容:
find $BASE_DIR -type d -ctime +90 -exec rm -rf {} \;
该脚本成功删除了目录,但同时也出现了以下错误:
find: 0652-081 cannot change directory to <actual_path>:
: A file or directory in the path name does not exist.
这里唯一需要注意的是 $BASE_DIR 指向的是虚拟位置,而错误信息中的 actual_path 指向的是实际位置。环境中存在软链接。
find $BASE_DIR -type d -ctime +90
的输出结果?看起来它正在尝试删除的目录已经被删除了,因此无法引用指向它的符号链接。 - jkshah-depth
似乎可以消除这个错误。谢谢! - citsym