日志切割脚本

  • 多域名脚本切割
#!/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
点赞

发表评论

电子邮件地址不会被公开。 必填项已用*标注