#!/bin/bash #log path LOGS_PATH=/application/nginx/logs #pid path pid=/application/nginx/logs/nginx.pid #day DAY=$(date -d "yesterday" +%Y-%m-%d) mv -f ${LOGS_PATH}/error.log ${LOGS_PATH}/error_${DAY}.log #week #WEEKS=$(date -d "yesterday" +%u) #mv -f ${LOGS_PATH}/access.log ${LOGS_PATH}/access_${WEEKS}.log #The new open log kill -USR1 $(cat $pid) #delete log 10 day before #find ${LOGS_PATH} -name "access_*.log" -type f -mtime +10 -exec rm {} ; find ${LOGS_PATH} -name "error*.log" -type f -mtime +30 | xargs rm -f
#!/bin/bash #log path LOGS_PATH=/application/nginx/logs #pid path pid=/application/nginx/logs/nginx.pid #day DAY=$(date -d "yesterday" +%Y-%m-%d) mv -f ${LOGS_PATH}/access.log ${LOGS_PATH}/access_${DAY}.log #week #WEEKS=$(date -d "yesterday" +%u) #mv -f ${LOGS_PATH}/access.log ${LOGS_PATH}/access_${WEEKS}.log #The new open log kill -USR1 $(cat $pid) #delete log 10 day before #find ${LOGS_PATH} -name "access_*.log" -type f -mtime +10 -exec rm {} ; find ${LOGS_PATH} -name "access_*.log" -type f -mtime +30 | xargs rm -f