#!/bin/bash

export YESTERDAY=$(date -d "yesterday" +%Y-%m-%d)

[ -d /var/log/nginx ] &&  export LOG_PATH=/var/log/nginx

log_exc(){

    mv $filename $LOG_PATH/$YESTERDAY.$filename

}

log_files = `ll /var/log/*.log| awk -F/ '{print $NR}'`

for i in ${log_files[*]}

do

    filename = $i

    log_exc

done

NGINX_PID=`cat /var/run/nginx.pid`

kill -USR1 $NGINX_PID

#计划任务

1 0 * * * /bin/bash /opt/scripts/nginx_log_cut.sh