当前位置: 代码迷 >> Web前端 >> NGINX 多域名日记切割备份脚本
  详细解决方案

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

热度:515   发布时间:2012-11-26 11:48:49.0
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