Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PM2 日志自动切割 #152

Closed
Dream4ever opened this issue Jun 15, 2021 · 0 comments
Closed

PM2 日志自动切割 #152

Dream4ever opened this issue Jun 15, 2021 · 0 comments
Labels
Server The invisible hero Software About installation ande usage

Comments

@Dream4ever
Copy link
Owner

解决过程

在 PM2 官方文档中,提到可以安装 pm2-logrotate 这个库,来实现 PM2 日志的自动切割。

先执行命令 pm2 install pm2-logrotate 安装这个库。

然后执行下面的命令,对日志切割的选项进行配置:

# 单个日志文件体积超过 100M 后则自动切割
$ pm2 set pm2-logrotate:max_size 100M

# 保存最近 60 天的日志文件,更早的都删除
$ pm2 set pm2-logrotate:retain 60

# 对切割出来的旧日志文件进行 gzip 压缩
$ pm2 set pm2-logrotate:compress true
@Dream4ever Dream4ever added Server The invisible hero Software About installation ande usage labels Jun 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Server The invisible hero Software About installation ande usage
Projects
None yet
Development

No branches or pull requests

1 participant