时间:2021-07-01 10:21:17 帮助过:25人阅读
创建 日志 分割 脚本 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