NGINX 多域名日志切割备份脚本

#!/bin/bash
# Info   : cut logs for nginx
# Author : elain
# CTime  : 2011.06.08
# This script run at 00:00

# The Nginx logs path
Logs_Path=”/elain/logs/nginx”
log_filenames=`/bin/ls $Logs_Path |grep -v nginx|grep -v logsbak`

for log_name in $log_filenames
do
/bin/mv $Logs_Path/$log_name $Logs_Path/logsbak/`date -d yesterday +%Y%m%d%H%M`-$log_name
done

kill -USR1 `cat /elain/apps/nginx/nginx.pid`

cron定时任务

# Info   : 每天凌晨0点切割一次NGINX日志
# Author : elain
# CTime  : 2011.06.08
00 00 * * * /root/scripts/cut_nginx_log.sh

相关推荐