nginx日志切割

每天产生一个nginx日志,操作步骤如下:


一:vim /sh/cut_nginx.sh

   

#!/bin/bash
########cut nginxlog  by day ###########
LOGS_PATH=/var/log/nginx
YESTERDAY=$(date -d "yesterday" +%Y%m%d)
mv ${LOGS_PATH}/nginx_access.log ${LOGS_PATH}/nginx_access_${YESTERDAY}.log
mv ${LOGS_PATH}/nginx_error.log ${LOGS_PATH}/nginx_error_${YESTERDAY}.log
kill -USR1 $(cat /usr/local/nginx/logs/nginx.pid)


二:chmod u+x cut_nginx.sh


三:crontable -e

    00 00 */1 * *  bash /sh/cut_nginx_log.sh > /dev/null 2>&1



你可能感兴趣的:(nginx日志切割)