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