Skip to content

Instantly share code, notes, and snippets.

@theharveyz
Forked from simsicon/logrotate.conf
Last active March 6, 2017 18:48
Show Gist options
  • Save theharveyz/d1ca1274bdc9351c4e0f5eb20aba92d1 to your computer and use it in GitHub Desktop.
Save theharveyz/d1ca1274bdc9351c4e0f5eb20aba92d1 to your computer and use it in GitHub Desktop.
Helpful logrotate configuration
/var/log/app.log {
weekly
missingok
su root root # 切换到某个用户\组
create 0664 root utmp # 指定日志用户以及 模式
rotate 52
compress
delaycompress
notifempty
copytruncate
}
# 其中 daily 表示每天整理,也可以改成 weekly 或 monthly
# dateext 表示檔案補上 rotate 的日期
# missingok 表示如果找不到 log 檔也沒關係
# rotate 7 表示保留65535份
# compress 表示壓縮起來,預設用 gzip。不過如果硬碟空間多,不壓也沒關係。
# delaycompress 表示延後壓縮直到下一次 rotate
# notifempty 表示如果 log 檔是空的,就不 rotate
# copytruncate 先複製 log 檔的內容後,在清空的作法,因為有些程式一定 log 在本來的檔名,例如 rails。另一種方法是 create。
# sharedscripts 表示日志文件都轮转完毕后统一执行一次脚本
# postrotate
# kill -USR1 `cat /var/run/nginx.pid`
# endscript
@theharveyz
Copy link
Author

logrotate 配置项

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment