1. #!/bin/bash
    2. LOG_DIR=/usr/local/nginx/logs
    3. YESTERDAY_TIME=$(date -d "yesterday" +%F)
    4. LOG_MONTH_DIR=$LOG_DIR/$(date +"%Y-%m")
    5. LOG_FILE_LIST="default.access.log"
    6. for LOG_FILE in $LOG_FILE_LIST; do
    7. [ ! -d $LOG_MONTH_DIR ] && mkdir -p $LOG_MONTH_DIR
    8. mv $LOG_DIR/$LOG_FILE $LOG_MONTH_DIR/${LOG_FILE}_${YESTERDAY_TIME}
    9. done
    10. kill -USR1 $(cat /var/run/nginx.pid)