#!/bin/bash # This script run at 00:00 # 00 00 * * * log_daily.sh # The Nginx logs path LOG_PATH="/usr/local/nginx/logs" for log in `ls $LOG_PATH`; do echo $log | grep '.log$' > /dev/null if [ $? -eq 0 ];then NEW_LOG_FILE_PATH=$LOG_PATH/${log}_`date -d yesterday +%Y_%m_%d` mv $LOG_PATH/$log $NEW_LOG_FILE_PATH chmod 666 $NEW_LOG_FILE_PATH fi done # ask nginx to generate new log file kill -USR1 `cat /usr/local/nginx/var/nginx.pid`?
?