首页 > 系统 > Linux > 正文

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

2019-11-02 16:41:07
字体:
来源:转载
供稿:网友

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 &#------------------------------------#paramsarchlog_path=/db2backup/archlogbackup_path=/db2backup/backupfind $archlog_path -mtime +7 -name "S*.LOG" |xargs rm -ffind $backup_path -mtime +7 -name "*.tgz" |xargs rm -f

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表