Nginx log Segmentation

Source: Internet
Author: User
Create the log segmentation script virootcut_logs.sh #! Binbash # Thisscriptrunat00: 00 # TheNginxlogspathlogs_pathdatalogsmkdir-p $ {logs_path} $ (date-dyesterday + % Y) $ (date-dyesterday + % m) mv $ {logs_path} access. log $ {logs_path} $ (date

Create a log segmentation script vi/root/cut_logs.sh #! /Bin/bash # This script run at 00:00 # The Nginx logs path logs_path =/data/logs/mkdir-p $ {logs_path} $ (date-d yesterday + % Y) /$ (date-d yesterday + % m)/mv $ {logs_path} access. log $ {logs_path} $ (date

CreateLogsSplitScript

Vi/root/cut_logs.sh

#! /Bin/bash

# This script run at 00:00

# The Nginx logs path

Logs_path = "/data/logs /"

Mkdir-p $ {logs_path} $ (date-d "yesterday" + "% Y")/$ (date-d "yesterday" + "% m ")/

Mv $ {logs_path} access. log $ {logs_path} $ (date-d "yesterday" + "% Y")/$ (date-d "yesterday" + "% m ") /access _ $ (date-d "yesterday" + "% Y % m % d "). log

/Usr/local/nginx/sbin/nginx-s reload

Set the execution permission of cut_logs.sh

Chmod + x/root/cut_logs.sh

Cut_logs.shAutomatic execution time

00 00 ***/root/cut_logs.sh

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.