mkdir /home/temp/shell
cd /home/temp/shell
vim auto-del-180-days-ago-logdatafiles.sh
输入shell文件内容:
#!/bin/sh
find /usr/logdata/logdata/ftp/files -name "*.tar.gz" -mtime 192 -exec rm -rf {} \;
设置shell文件的可执行权限:
chmod +x auto-del-180-days-ago-logdatafiles.sh
创建crontab定时任务,后台周期性执行shell文件:
crontab -e
10 0 * * * /home/temp/shell/auto-del-180-days-ago-logdatafiles.sh
重新启动crontab服务:
systemctl restart crond.service
查看crontab服务运行状态:
systemctl status crond.service