Cron Job 在 Centos 中自动删除超过 7 天的文件夹
Cron Job to auto delete folder older than 7 days in Centos
我在 centos 中有一个文件夹,里面有大文件,以及如何删除超过 30 分钟的文件。
请提出您的想法和片段
很简单。只需使用 find
并在 crontab
中添加以下行:
30 * * * * find /path/to/dir -type f -mmin +30 -exec rm -f {} \;
上述命令将 运行 每 30 分钟一次,并仅从目录 /path/to/dir
中删除 30 分钟前的文件
我在 centos 中有一个文件夹,里面有大文件,以及如何删除超过 30 分钟的文件。
请提出您的想法和片段
很简单。只需使用 find
并在 crontab
中添加以下行:
30 * * * * find /path/to/dir -type f -mmin +30 -exec rm -f {} \;
上述命令将 运行 每 30 分钟一次,并仅从目录 /path/to/dir