cat del.sh

#!/bin/bash

thirty=`date -d '30days ago' +%Y-%m-%d`
cd $1

#删除输入路径下第30天的日志文件
find . -name "*$thirty*" -type f | xargs -I {} rm -f {}

利用crontab每天执行,每天删除据现在第30天的日志

40 1 * * * /usr/local/cleanlog/del.sh

 

欢迎转载,请注明出处

相关文章:

  • 2022-01-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-03-08
  • 2021-08-10
猜你喜欢
  • 2021-11-25
  • 2021-06-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-13
相关资源
相似解决方案