Install PM2 Log rotate offline

1. Install pm2-logrotate from online computer with command

pm2 install pm2-logrotate

2. Compress file pm2-logrotate from pm2 module path

cd /root/.pm2/modules/
tar czvf pm2-logrotate.tgz pm2-logrotate/

3. Copy pm2-logrotate to offline computer

4. Decompress file to pm2 module path

cd /root/.pm2/modules/
tar xzvf pm2-logrotate.tgz

5. Start pm2 with command

pm2 start --name "pm2-logrotate"  /root/.pm2/modules/pm2-logrotate/node_modules/pm2-logrotate/app.js

pm2 save

If you want to change schedule, you can configure from file

vim /root/.pm2/modules/pm2-logrotate/node_modules/pm2-logrotate/package.json
 "config": {
    "max_size": "10M",
    "retain": "90",
    "compress": false,
    "dateFormat": "YYYY-MM-DD_HH-mm-ss",
    "workerInterval": "30",
    "rotateInterval": "0 0 * * *",
    "rotateModule": true

3 Replies to “Install PM2 Log rotate offline”

  1. Thanks! One small correction of specifiying app.js rather than app.json

    pm2 start –name “pm2-logrotate” /root/.pm2/modules/pm2-logrotate/node_modules/pm2-logrotate/app.js

  2. Hello. Please understand that I can not speak English well.

    Your posting has been great help.

    So is it okay to use my blog to write a source?

    Please answer by my email 🙂

    Thank you.

Leave a Reply

Your email address will not be published. Required fields are marked *