shell 删除七日内日志_写了一个shell,删除15天以上日志

该博客提供了一个Shell脚本用于删除指定目录下15天以上的日志文件。脚本中定义了多个日志文件所在的目录,通过find命令结合-mtime参数查找符合条件的文件或目录,并使用rm -rf命令将其删除。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#!/bin/bash

#author:qinliang

#date:1.7.2020

#note:keep 15 days log

location1="/data/backup/xxx"

location2="/data/log/xxx"

location3="/data/log/xxxx/xx"

location4="/data/log/xxxx/xx"

location5="/data/log/xxxx/xx"

find $location1 -mtime +15 -type d |xargs rm -rf;

find $location2 -mtime +15 -name "[0-9]*.log" -exec rm -rf {} \;

find $location3 -mtime +15 -name "curl2_*.log" -exec rm -rf {} \;

find $location4 -mtime +15 -name "lopt_refere_*.log" -exec rm -rf {} \;

find $location4 -mtime +15 -name "login_oas_nk_*.log" -exec rm -rf {} \;

find $location4 -mtime +15 -name "get_*.log" -exec rm -rf {} \;

find $location4 -mtime +15 -name "db2_*.log" -exec rm -rf {} \;

find $location4 -mtime +15 -name "db_*.log" -exec rm -rf {} \;

find $location4 -mtime +15 -name "curl2_*.log" -exec rm -rf {} \;

find $location5 -mtime +15 -name "lopt_refere_*.log" -exec rm -rf {} \;

find $location5 -mtime +15 -name "get_*.log" -exec rm -rf {} \;

find $location5 -mtime +15 -name "download_*.log" -exec rm -rf {} \;

find $location5 -mtime +15 -name "db_*.log" -exec rm -rf {} \;

find $location5 -mtime +15 -name "curl2_*.log" -exec rm -rf {} \;

find $location5 -mtime +15 -name "curl_*.log" -exec rm -rf {} \;

find $location5 -mtime +15 -name "client_open_*.log" -exec rm -rf {} \;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值