Nginx Log Cutting script, automatically upload to the log server

Source: Internet
Author: User

Nginx Log Cutting script, automatically upload to the log server

1 Nginx is the Yum mode installation, the system will automatically generate Nginx log cutting schedule task under/etc/logrotate.d/nginx, the automatic generation of scheduled tasks deleted, write their own cutting scripts, and upload to the unified log server. Www.ahlinux.com

2 Install the NCFTP package for use in log transfer.

3 simple cut scripts are as follows:

#!/bin/bash

Path=/bin:/sbin:/usr/bin:/usr/sbin

Export PATH

yesterday= ' Date +%y%m%d-d '-1 day '

Cd/var/log/nginx

MV Access.log Test_ip_$yesterday.log

KILL-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_$yesterday.log.gz

4 hours a day, 1 minutes of execution.

0 1 * * */root/putaccess.sh

  • This article is from: Linux Learning Network

Nginx Log Cutting script, automatically upload to the log server

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.