0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
wget https://fossies.org/linux/www/old/cronolog-1.6.2.tar.gz cd cronolog-1.6.2 ./configure && make && make install [root@www bin]# diff catalina.sh* 206,207c206 < #CATALINA_OUT="$CATALINA_BASE"/logs/catalina.out < CATALINA_OUT="$CATALINA_BASE"/logs/catalina.out.%Y-%m-%d --- > CATALINA_OUT="$CATALINA_BASE"/logs/catalina.out 419c418 < #touch "$CATALINA_OUT" --- > touch "$CATALINA_OUT" 432,433c431,432 < org.apache.catalina.startup.Bootstrap "$@" start 2>&1 \ < | /usr/local/sbin/cronolog "$CATALINA_OUT" >> /dev/null & --- > org.apache.catalina.startup.Bootstrap "$@" start \ > >> "$CATALINA_OUT" 2>&1 "&" 441,442c440,441 < org.apache.catalina.startup.Bootstrap "$@" start 2>&1 \ < | /usr/local/sbin/cronolog "$CATALINA_OUT" >> /dev/null & --- > org.apache.catalina.startup.Bootstrap "$@" start \ > >> "$CATALINA_OUT" 2>&1 "&" |
nginx日志切割:【必须先启动cronolog,然后启动nginx】
0 1 2 3 |
$ mkfifo /usr/local/nginx/logs/access_log_pipe #建立管道 $ cat /usr/local/nginx/logs/access_log_pipe | /usr/local/cronolog/sbin/cronolog /usr/local/nginx/logs/access_%Y%m%d.log & #天 $ cat /usr/local/nginx/logs/access_log_pipe | /usr/local/cronolog/sbin/cronolog /usr/local/nginx/logs/access_%Y%m%d%H.log & #小时 $ cat /usr/local/nginx/logs/access_log_pipe | /usr/local/cronolog/sbin/cronolog /usr/local/nginx/logs/access_%Y%m%d%H%M.log & #分钟 |
nginx日志代码:
0 1 2 3 4 |
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 logs/access_log_pipe main; |
申明:除非注明Byrd's Blog内容均为原创,未经许可禁止转载!详情请阅读版权申明!