Nginx日志清理

#!/bin/bash
log_dir="/Data/log"
time=`date +%Y%m%d`  
/bin/mv  ${log_dir}/nginx-access.log ${log_dir}/nginx-access.$time.log
kill -USR1 `cat  /var/run/nginx.pid`

 

Log Rotation

nginx will re-open it's logs in response to the USR1 signal.

$ mv access.log access.log.0
$ kill -USR1 <code>cat master.nginx.pid</code>
$ sleep 1
$ gzip access.log.0    # do something with access.log.0
可以按照日期来切割保存日志

你可能感兴趣的:(nginx,bash,Access)