简体   繁体   中英

PM2 Log Rotate Weekly Configuration

I'm so confused with the pm2-logrotate configuration, i need some help. I've search for documentation and googled with zero result. I just want to rotate the log every week.

I've tried using pm2 set pm2-logrotate:rotateInverval 0 0 * * 0 but the log file generated daily.

I just don't understand that cron stuff and i need some explaination, can somebody explain it to me?

thank you in advance.

While your cronjob seems fine. But there are some other configurations also associated with pm2-logrotate. Like max_size , the default max size of log is 10 MB, if your log exceeds that then pm2 will rotate it. Say, you want to change it to 10GB, then issue this command pm2 set pm2-logrotate:max_size 10G . You can specify the size as you wish 10K, 10M, 10G . I have faced a similar problem when the log got rotated 3-4 times a day instead of following the specified frequency.

Without being wrapped in quotation marks, it's likely that only the first 0 is being read in your interval. So instead of interpreting the interval as 0 0 * * 0 , it is interpreted just as 0 .

The following should do the trick:

pm2 set pm2-logrotate:rotateInverval "0 0 * * 0"

As for understanding the cron syntax, try pasting the values in here for an explanation: https://crontab.guru/#0_0_ _ _0

Your problem is caused because you spelled rotateInterval wrong.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM