nginx 로그 절단 소계

#!/bin/bash
## Nginx          
LOGS_PATH=/usr/local/nginx/logs/
TODAY=$(date +%Y-%m-%d)
LASTHOUR=$(date +%Y-%m-%d:%H -d '-1 hours')
FILE_PATH=$LOGS_PATH$TODAY
 
 
#            
if [ ! -x "$FILE_PATH" ]
	then 
		mkdir $FILE_PATH
fi
 
#                 
mv ${LOGS_PATH}/access.log ${FILE_PATH}/access_${LASTHOUR}.log
mv ${LOGS_PATH}/error.log ${FILE_PATH}/error_${LASTHOUR}.log
#      
kill -USR1 $(cat /usr/local/nginx/logs/nginx.pid)

좋은 웹페이지 즐겨찾기