Nginx Cutting Log

Source: Internet
Author: User

#!/bin/bash## filename:    nginxcutlog.sh# author:       qicheng# website:     http://qicheng0211.blog.51cto.com/# description :  cut nginx Log # notes:        settings crontab, daily 23:59 scheduled execution #root_uid=0if  [  "$UID"  -ne  "$ROOT _uid"  ];then    echo  "error:  This program must be run as root user! "    exit 1fi nginx_logs_dir="/data/log/nginx "nginx_pid_file="/var/run/nginx.pid "#  the log file name after the cut, such as 54_access_20141022.lognginx_log_today=" $nginx _logs_dir/54_access_ ' date +%y%m%d '. Log "[  -f  "$nginx _log_today"  ] && exit 1mv  $nginx _logs_dir/54_access.log   $nginx _log_today#  send USR1 signal to Nginx to reopen the new Access.log log file [ -f  $nginx _pid_file ]  && /bin/kill -usr1 $ (cat  $nginx _pid_file) Chown www:www /data/log/nginx  -rchMod 755 /data/log/nginx/*/usr/local/nginx/sbin/nginx -s reload 


This article is from the "Xiangjiang River Blowing Crazy" blog, please make sure to keep this source http://xjcf00.blog.51cto.com/10170403/1642566

Nginx Cutting Log

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.