惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
G
Google Developers Blog
B
Blog
Engineering at Meta
Engineering at Meta
阮一峰的网络日志
阮一峰的网络日志
The Register - Security
The Register - Security
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 叶小钗
The Cloudflare Blog
The Hacker News
The Hacker News
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
雷峰网
雷峰网
F
Fortinet All Blogs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hackread – Cybersecurity News, Data Breaches, AI and More
酷 壳 – CoolShell
酷 壳 – CoolShell
Last Week in AI
Last Week in AI
T
Threat Research - Cisco Blogs
A
About on SuperTechFans
量子位
Recorded Future
Recorded Future
博客园 - 三生石上(FineUI控件)
H
Help Net Security
Help Net Security
Help Net Security
P
Palo Alto Networks Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Troy Hunt's Blog
W
WeLiveSecurity
V
Vulnerabilities – Threatpost
T
The Exploit Database - CXSecurity.com
Know Your Adversary
Know Your Adversary
Apple Machine Learning Research
Apple Machine Learning Research
Scott Helme
Scott Helme
N
News | PayPal Newsroom
AWS News Blog
AWS News Blog
D
DataBreaches.Net
Blog — PlanetScale
Blog — PlanetScale
MongoDB | Blog
MongoDB | Blog
B
Blog RSS Feed
腾讯CDC
J
Java Code Geeks
Microsoft Azure Blog
Microsoft Azure Blog
TaoSecurity Blog
TaoSecurity Blog
GbyAI
GbyAI
Y
Y Combinator Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
D
Docker

博客园 - builderman

运行abp install-libs的时候,提示"NPM is not installed"的原因及解决办法 nginx 基本操作 nginx 正向代理与反正代理的区别及简单配置 KeyCloak基础概念 修改linux终端中当前用户的显示颜色 minikube使用笔记 ssh端口转发 kubectl proxy 让外部网络访问K8S service的ClusterIP 记录一下我在ubuntu下安装 minikube的过程 ssh ssh-keygen 私钥 docker vscode server docker network docker mysql8 phpmyadmin linux 压缩与解压缩 Ubuntu添加开机自动启动程序的方法 Linux基本命令集合 linux下使用supervisor启动.net core mvc website的配置 小修改,让mvc的验证锦上添点花(2) 小修改,让mvc的验证锦上添点花(1)
用crontab定时分隔nginx日志文件
builderman · 2021-02-22 · via 博客园 - builderman

1.创建/data/cut_nginx_logs.sh

#!/bin/bash
#function:cut nginx log files
#author: http://lnmp.org

#set the path to nginx log files
log_files_path="/data/wwwlogs/"
log_files_dir=${log_files_path}$(date -d "yesterday" +"%Y")/$(date -d "yesterday" +"%m")
#set nginx log files you want to cut
log_files_name=(a.domain.com b.domain.com)
#set the path to nginx.
nginx_sbin="/usr/sbin/nginx"
#Set how long you want to save
save_days=30

############################################
#Please do not modify the following script #
############################################
mkdir -p $log_files_dir

log_files_num=${#log_files_name[@]}

#cut nginx log files
for((i=0;i<$log_files_num;i++));do
        mv ${log_files_path}${log_files_name[i]}.log ${log_files_dir}/${log_files_name[i]}_$(date -d "yesterday" +"%Y%m%d").log
done

#delete 30 days ago nginx log files
find $log_files_path -mtime +$save_days -exec rm -rf {} \;

$nginx_sbin -s reload

2. 增加执行权限 

chmod +x /data/cut_nginx_logs.sh

3.修改/etc/crontab文件,以最后面加上以下代码,表示每天0点0分执行脚本 /data/cut_nginx_logs.sh

0 0 * * *   root    /data/cut_nginx_logs.sh

可以用select-editor来修改crontab默认的编辑器