nginx日志切割脚本
#!/bin/bash # ngxin log切割脚本 LOGS_PATH=/usr/local/nginx/logs/history CUR_LOGS_PATH=/usr/local/nginx/logs YESTERDAY=$(date -d "yesterday" +%Y-%m-%d) mv ${CUR_LOGS_PATH}/access.log ${LOGS_PATH}/access_${YESTERDAY}.log mv ${CUR_LOGS_PATH}/error.log ${LOGS_PATH}/error_${YESTERDAY}.log # 向ngxin主进程发送USR1信号,使其重新打开日志 kill -USR1 $(cat /usr/local/nginx/logs/nginx.pid)
脚本名:rotate.sh