Nginx log cutting script, automatically uploaded to the log server

Source: Internet
Author: User

The nginx log cutting script is automatically uploaded to the log server. 1 nginx is installed in yum mode. The system automatically generates the nginx log cutting plan task in/etc/logrotate. d/nginx: Delete the automatically generated scheduled task, write the cut script by yourself, and upload it to the server that stores logs in a unified manner. Install the ncftp package at www.2cto.com 2 for log transmission. 3 simple cut Script :#! /Bin/bashPATH =/bin:/sbin:/usr/bin: /usr/sbinexport PATHyesterday = 'date + % Y % m % d-d'-1 Day' cd/var/log/nginxmv access. log test_ip _ $ yesterday. logkill-USR1 'cat/var/run/nginx. pid 'gzip test_ip _ $ yesterday. log/usr/local/bin/ncftpput-u log-p 123456 192.168.1.1 test_ipdir test_ip_1_yesterday.log.gz 4 run 0 1 ***/root/putaccess at every day. 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.