日志轮转 logrotate 配置
配置项
vim /etc/logrotate.d/hzero-logs
统一用户的配置版本
/data/hzero/jar/logs/*.log {
daily # 每天轮转
rotate 7 # 保留最近7个历史文件
size 100M # 日志大小超过100M就立刻轮转
compress # 轮转后压缩
missingok # 不存在的文件不报错
notifempty # 如果文件为空也不轮转
copytruncate # 轮转后通过 copytruncate 方式保留旧文件名并不重启服务(copytruncate);
}
区分日志的所属和所属组的版本
# 针对 op 用户写的日志
/data/hzero/jar/logs/h0-bai.log
/data/hzero/jar/logs/h0-config.log
/data/hzero/jar/logs/h0-im.log
/data/hzero/jar/logs/h0-invoice.log
/data/hzero/jar/logs/h0-kms.log
/data/hzero/jar/logs/h0-pay.log
/data/hzero/jar/logs/h0-printer.log
/data/hzero/jar/logs/h0-search.log
/data/hzero/jar/logs/h0-todo.log
/data/hzero/jar/logs/h0-webexcel.log
/data/hzero/jar/logs/h0-workflow-plus.log {
daily
rotate 7
size 100M
compress
missingok
notifempty
copytruncate
su op op
}
# 针对 root 用户写的日志
/data/hzero/jar/logs/h0-gateway.log
/data/hzero/jar/logs/h0-iam-saas.log
/data/hzero/jar/logs/h0-interface.log
/data/hzero/jar/logs/h0-message.log
/data/hzero/jar/logs/h0-monitor.log
/data/hzero/jar/logs/h0-oauth.log
/data/hzero/jar/logs/h0-rule-engine.log {
daily
rotate 7
size 100M
compress
missingok
notifempty
copytruncate
su root root
}
手动测试
# debug方式,不会真正执行
logrotate -dv /etc/logrotate.d/hzero-logs
# 想要手动执行
# logrotate -v /etc/logrotate.d/hzero-logs
浙公网安备 33010602011771号