1.环境
rhel6.1_x86_64bit
2.nginx分割脚本
vim /root/nginx-log.sh
#!/bin/bash
log_dir=/www/log/
date=`date +%Y%m%d%H`
mv ${log_dir}gaojinbo.com.log ${log_dir}gaojinbo.com.${date}.log
kill -USR1 `cat /var/run/nginx.pid`
3.增加执行权限
chmod +x /root/nginx-log.sh
4.nginx日志格式
log_format main
'$remote_addr - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"' ;
access_log /www/log/gaojinbo.com.log main;
5.添加到crond
添加到crond,每59分钟执行一次,误差1分钟
crontab -e
59 * * * * /root/nginx-log.sh
阅读(2191) | 评论(0) | 转发(0) |