nginx 日志分割

1. 配置文件校验

 ./nginx -t   

2.日志切割

   mv access.log access.log.2019..07.06

  # kill -USR1 (nginx master proccess id)

   kill -USR1  32989     

   每天定时操作上面的命令 (crontab)

 [root@weblogic scripts]# cat nginx_sin.sh

#!/bin/bash
 
log_path=/var/log/nginx
YESTERDAY=`date -d "yesterday" +%Y-%m-%d_%S`
nginx_cmd="/usr/sbin/nginx"
 
/bin/mv ${log_path}/access.log ${log_path}/access.$YESTERDAY.log
/bin/mv ${log_path}/error.log  ${log_path}/error.$YESTERDAY.log
 
# send a signal
/bin/kill -USR1 `ps axu | grep "nginx: master process" | grep -v grep | awk '{print $2}'`

[root@weblogic scripts]#crontab -l

0 0 * * * /bin/bash /root/scripts/nginx_sin.sh
posted @ 2019-07-06 14:08  newlangwen  阅读(121)  评论(0编辑  收藏  举报