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

posted @ 2019-07-19 14:48  落魄山陈平安  阅读(158)  评论(0编辑  收藏  举报