Linux Shell:nginx log Cutting scripts

Source: Internet
Author: User
Requirement Reason: Nginx does not have the log cutting function, the log volume is large, convenient analysis. Implementation purpose: Complete Nginx log cutting, and according to the time named Brief command: Mv/usr/local/tengine/logs/access.log/usr/local/tengine/logs/access-date.logkill- USER1 Nginx main process number. Explanation: Through the MV command to rename the log, and through the Kill-user1 nginx-id command, tell Nginx to write a new log, or Nginx will not continue to write the log after the MV. We can get the main process number of Nginx by Nginx.pid file. Kill-user1 ' Cat/usr/local/tengine/logs/nginx.pid ' detailed script is as follows: ####################################################### #################!/bin/bashlogs_bak_path= "/usr/local/tengine/logs/wanbu_nginx_log" logs_path= "/usr/local/ Tengine/logs "time=" date "+%y-%m-%d" ' mv $logs _path/wanbu.access.log $logs _bak_path/wanbu.access. $TIME. Logkill- USER1 ' Cat/usr/local/tengine/logs/nginx.pid '

Linux Shell:nginx log Cutting scripts

Related Article

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.