我正在编写一个shell脚本来运行一个MySQL备份作为一个cron作业,并遇到一个问题,而不是在机架空间云网站cron环境中支持find命令。 任何使用find命令的尝试都会给出:/ usr / bin / find:Permission denied
还有什么可以做的:
find *.gz -mtime +7 -delete
当这些文件被命名为这样的时候:
gzip > /mnt/target03/rest-of-path/web/backups/DATABASENAME_`date "+%Y-%m-%d"`.gz
?
我希望我可以parsing文件的date,而不使用循环查找,如下所示:
FILES=./path/to/files/* for f in $FILES do #delete files older than 7 days without using find done
我build议上传你自己的查找副本,如果它不存在。
如果这不起作用,使用File :: Find模块的Perl脚本可能会有用。
这可能是PATH环境问题。 作为一个评论者提到,你可能想要在你的cron中尝试完整的path。
尝试
whereis find which find locate find
看看你是否可以find完整的path来find。
在Red Hat系统上,find是findutils RPM的一部分,通常位于:
在/ usr / bin中/查找
所以重写你的cron为:
/usr/bin/find *.gz -mtime +7 -delete