• 日志清理


    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
    
     
  • 相关阅读:
    Electio Time poj
    排列的字典序问题
    poj 2365
    编程中的命名设计那点事(转)
    编程命名中的7+1个提示(转)
    poj 1664 放苹果——递归
    再论字典序
    poj 3618
    sort用法
    poj 1088
  • 原文地址:https://www.cnblogs.com/sseban/p/13426261.html
Copyright © 2020-2023  润新知