当前位置:   首页安装配置删除日志:Linux下自动删除归档日志文件的方法

删除日志:Linux下自动删除归档日志文件的方法

发布日期:2022-04-23 13:20 | 文章来源:脚本之家

1.日志删除策略

自动删除7天前的归档日志与备份文件。

2.调度计划

0 0 * * * nohup sh /db2backup/script/auto_rm_logs.sh &

3.日志删除脚本

auto_rm_logs.sh
#!/bin/sh
#-------------------------------------
# rm db2 archive log file and *.tgz files @hury
# create @2016-12-13
# script name:auto_rm_logs.sh
# 1.chmod 744 auto_rm_logs.sh
# 2.crontab -e 
# for test only
# */2 * * * * nohup sh /db2backup/script/auto_rm_logs.sh &
# for official
# 0 0 * * * nohup sh /db2backup/script/auto_rm_logs.sh &
#------------------------------------
#params
archlog_path=/db2backup/archlog
backup_path=/db2backup/backup
find $archlog_path -mtime +7 -name "S*.LOG" |xargs rm -f
find $backup_path -mtime +7 -name "*.tgz" |xargs rm -f

联系我们
关于使用场景和技术架构的更多咨询,请联系我们的销售和技术支持团队。
Yingsoo Host

在线
客服

在线客服:7*24小时在线

客服
热线

400-630-3752
7*24小时客服服务热线

关注
微信

关注官方微信
顶部