• 日志清理


    1.由于java项目问题,如下路径会生成以时间格式命名的目录,目录下存在大量的log日志。
    
    /data/applogs/xxl-job/jobhandler/2020-08-03
    
    #!/bin/bash
    # File Name: delete_log.sh
    # Version: V1.0
    # Author: Songyifei
    # Organization: www.apolls.cn
    # Created Time : 2020-08-03 11:31:56
    # Description:
    #############################################################
    Path=/data/applogs/xxl-job/jobhandler/
    time=`date +%Y-%m-%d`
    webhook='https://oapi.dingtalk.com/robot/send?access_token=87553735f7b1c338839c4c5fd7dc388a586df67920f1e1a48ea8487bea8492b7'
    a=True
    b=False
    host=`ifconfig eth0 |awk -F '[ :]+' 'NR==2 {print $3}'`
    myPath="/server/tmp/"
    if [ ! -d ${myPath} ];then
    mkdir -p ${myPath}
    else
    echo dir exist
    fi
    yum -y install rsync
    #for i in `find ${Path}${time} -name *.log`;
    for i in `ls ${Path}${time}`
    do 
    rsync --delete-before -a -H --progress --stats ${myPath} ${Path}${time}
    if [ $? -ne 0 ];then
    c=`echo $b`
    else
    c=`echo $a`
    fi
    done
    
    
    function SendMsgToDingding() {
    curl $webhook -H 'Content-Type: application/json' -d "
    {
    'msgtype': 'text',
    'text': {
    'content': '告警主题:$Path${time}日志清理 
    主机IP: $host
     Status: ${c} 
     触发动作: Delete 
     '
    },
    'at': {
    'isAtAll': true
    }
    }"
    }
    
    SendMsgToDingding
    
     
  • 相关阅读:
    课堂训练
    测试用例
    学生空间测试
    图书管理系统为例5w1h
    风险分析
    关于选择方案的练习作业
    图书管理系统需求报告书
    电梯演说模板
    对于敏捷开发的见解
    课堂练习2
  • 原文地址:https://www.cnblogs.com/sseban/p/13426261.html
Copyright © 2020-2023  润新知