1、新建腳本bash
vi auto_del.sh
2、刪除/otp/myPhtots/2019/06下 昨天的文件code
year=`date +%Y` month=`date +%m` echo "/opt/myPhotos/$year/$month" find /opt/myPhotos/$year/$month -mtime 1 -type d -name "*" -exec rm -rf {} \;
3、新建crontab定時任務crontab
crontab -e
0 11 * * * /opt/auto_del.sh
crontab -l //查看當前用戶下全部定時任務