Home  >  Article  >  Database  >  Nginx日志分割

Nginx日志分割

WBOY
WBOYOriginal
2016-06-07 15:06:351355browse

创建 日志 分割 脚本 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

创建日志分割脚本

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

设置cut_logs.sh执行权限

chmod +x /root/cut_logs.sh

cut_logs.sh自动执行时间

00 00 * * * /root/cut_logs.sh

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn