侧边栏壁纸
博主头像
cn2linux博主等级

行动起来,活在当下

  • 累计撰写 128 篇文章
  • 累计创建 1 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

草稿:日志切割脚本

#!/bin/bash

WEBNAME=(www_domain)
LOGTYPE=(error access)
SERPATH=/usr/local/nginx
LOGPATH=${SERPATH}/logs
BINPATH=${SERPATH}/sbin/nginx
DATETIME=$(date +%F)

function reloading(){
 ${SERPATH}/sbin/nginx -s reload
}

function cuter(){
 for name in ${!WEBNAME[*]}
 do
    for num in ${!LOGTYPE[*]}
    do
    mv ${LOGPATH}/${LOGTYPE[${num}]}_${WEBNAME[${name}]}.log  \
    ${LOGPATH}/${DATETIME}_${LOGTYPE[${num}]}_${WEBNAME[${name}]}.log
    done
 done
 reloading
}

function clearlog(){
 find ${LOGPATH} -type f -name "*.log"  -atime +7 \
 |xargs rm -f
}

cuter
#clearlog

0

评论区