一个精简的 nginx日志切割脚本

 

 

 

#!/bin/bash

#The script is run at 00:00
#The nginx logs
nginx_logs="/usr/local/webserver/nginx/logs/"
mkdir -p ${nginx_logs}/$(date -d "yesterday" "+%Y")/$(date -d "yesterday" +%m)/
mv ${nginx_logs}access.log ${nginx_logs}/$(date -d "yesterday" "+%Y")/$(date -d "yesterday" "+%m")/access_$(date -d "yesterday" "+%Y%m%d").log
kill -USR1 `cat ${nginx_logs}/nginx.pid`

你可能感兴趣的:(一个精简的 nginx日志切割脚本)