linux regularly delete yesterday's files

1. New script

vi auto_del.sh

2. Delete yesterday's files under /otp/myPhtots/2019/06

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. Create a new crontab scheduled task

crontab -e
0 11 * * * /opt/auto_del.sh
crontab -l
//查看当前用户下所有定时任务

 

{{o.name}}
{{m.name}}

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=324069853&siteId=291194637