【发布时间】:2011-12-21 16:37:26
【问题描述】:
请注意,我不能在目标环境中使用“查找”
我需要删除 linux shell 脚本中超过 7 天的所有文件。类似的东西:
FILES=./path/to/dir
for f in $FILES
do
echo "Processing $f file..."
# take action on each file. $f store current file name
# perhaps stat each file to get the last modified date and then delete files with date older than today -7 days.
done
我可以使用“stat”来执行此操作吗?我正在尝试使用
find *.gz -mtime +7 -delete
但发现我无法在目标系统上使用 find (cron 用户没有权限,并且无法更改)。目标系统是 Redhat Enterprise。
文件名的格式如下:
gzip > /mnt/target03/rest-of-path/web/backups/DATABASENAME_date "+%Y-%m-%d".gz
【问题讨论】: