定时删除日志

/bin/bash

cd /home/guolj/proxymanager/logs

find . -mtime +4 | xargs rm -rf

cd /home/guolj/lanproxy/proxy-server-0.1/logs

find . -mtime +4 | xargs rm -rf

#/bin/date >> /home/ema/crontab/1.log

crontab -e

* * * * * /bin/bash /home/guolj/crontab/del_log.sh

测试:

cd /home/guolj/proxymanager/logs
touch -mt 111.log
mkdir test
touch -mt test

观察1分钟,目录和日志被删除。

你可能感兴趣的:(定时删除日志)