Disable pm2 log creation in node js

10,519

We can user pm2 application declaration for our purpose and we can use:

Disabling logs
You can pass /dev/null to error_file or out_file to disable logs saving.

We can also set max_memory_restart parameter in process.json apps to set autorestart process on certain memory occupied by memory.example below for process.json:

{
  "apps" : [{
      "script": "worker.js",
      "watch": true,
      "max_memory_restart": "50M",
      "error_file": "/dev/null"
  }]
}
Share:
10,519
Ankit Badiya
Author by

Ankit Badiya

I am Working in software industry since 4 years. While working I have learnt Many technologies.Always ready to learn new technologies.

Updated on June 08, 2022

Comments

  • Ankit Badiya
    Ankit Badiya almost 2 years

    I am using aws ubuntu instance for my application and using node js to sync data from third party apis.

    I have 6 node js scripts that calls every minute to sync data by making http request for many users.

    For process management I am using PM2 module of node js.This pm2 creates logs for each running file ,this files size increasing tremendously and instance space occupied by log files.

    Is there any way to disable pm2 log creation?

  • VIKAS KOHLI
    VIKAS KOHLI over 4 years
    dev/null where need to add, can you share an example please
  • Admin
    Admin almost 4 years
    pm2 stop <process_id> and pm2 start <process_id> -o "/dev/null" -e "/dev/null"