nginx 日志切割(按小时)


vim /usr/local/nginx/sbin/log.conf  //写入以下内容

rotate 48
nocompress

/home/logs/access.log {
    sharedscripts
    create 0644 www www
    postrotate
        /bin/kill -USR1 `cat /usr/local/nginx/var/nginx.pid`
        LDATE=`date +%Y%m%d%H --date="-1 hour"`
        /bin/mv /home/logs/access.log.1 /home/logs/${LDATE}-access_log
    endscript
}

添加新评论 »