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

推荐订阅源

H
Help Net Security
月光博客
月光博客
IT之家
IT之家
B
Blog RSS Feed
T
Tailwind CSS Blog
The GitHub Blog
The GitHub Blog
博客园 - 三生石上(FineUI控件)
MyScale Blog
MyScale Blog
J
Java Code Geeks
Stack Overflow Blog
Stack Overflow Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - Franky
博客园 - 叶小钗
阮一峰的网络日志
阮一峰的网络日志
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
U
Unit 42
博客园_首页
B
Blog
V
V2EX
腾讯CDC
Vercel News
Vercel News
量子位
Microsoft Security Blog
Microsoft Security Blog

jobcher on 打工人日志

2023-12-21 打工人日报 2023-12-20 打工人日报 2023-12-19 打工人日报 2023-12-18 打工人日报 2023-12-17 打工人日报 2023-12-16 打工人日报 2023-12-15 打工人日报 2023-12-14 打工人日报 2023-12-13 打工人日报 2023-12-12 打工人日报 2023-12-11 打工人日报 2023-12-10 打工人日报 2023-12-09 打工人日报 2023-12-08 打工人日报 2023-12-07 打工人日报 2023-12-06 打工人日报 2023-12-05 打工人日报 2023-12-04 打工人日报 2023-12-03 打工人日报 2023-12-02 打工人日报 2023-12-01 打工人日报 2023-11-30 打工人日报 2023-11-29 打工人日报 2023-11-28 打工人日报 2023-11-27 打工人日报 2023-11-26 打工人日报 2023-11-25 打工人日报 2023-11-24 打工人日报 2023-11-23 打工人日报 2023-11-22 打工人日报
logrotate 日志滚动的使用
2021-12-29 · via jobcher on 打工人日志

logrotate 日志滚动的使用

logrotate 日志滚动切割工具,是 linux 默认安装的工具,配置文件位置:

1/etc/logrotate.conf
2/etc/logrotate.d/

参数

以 nginx 配置为例

 1/opt/log/nginx/*.log {
 2	daily
 3	missingok
 4	rotate 14
 5    errors "nb@nbtyfood.com"
 6	compress
 7	delaycompress
 8	notifempty
 9	create 0640 www-data adm
10	sharedscripts
11	prerotate
12		if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
13			run-parts /etc/logrotate.d/httpd-prerotate; \
14		fi \
15	endscript
16	postrotate
17		invoke-rc.d nginx rotate >/dev/null 2>&1
18	endscript
19}
参数作用
compress压缩日志文件的所有非当前版本
daily,weekly,monthly按指定计划轮换日志文件
delaycompress压缩所有版本,除了当前和下一个最近的
endscript标记 prerotate 或 postrotate 脚本的结束
errors “emailid”给指定邮箱发送错误通知
missingok如果日志文件丢失,不要显示错误
notifempty如果日志文件为空,则不轮换日志文件
olddir “dir”指定日志文件的旧版本放在 “dir” 中
postrotate引入一个在日志被轮换后执行的脚本
prerotate引入一个在日志被轮换前执行的脚本
rotate ’n'在轮换方案中包含日志的 n 个版本
sharedscripts对于整个日志组只运行一次脚本
size=‘logsize’在日志大小大于 logsize(例如 100K,4M)时轮换