LinuxCommandLibrary

pm2

Production process manager for Node.js

TLDR

Start application

$ pm2 start [app.js]
copy
Start with name
$ pm2 start [app.js] --name "[app_name]"
copy
List processes
$ pm2 list
copy
Stop process
$ pm2 stop [name|id]
copy
Restart process
$ pm2 restart [name|id]
copy
View logs
$ pm2 logs
copy
Monitor processes
$ pm2 monit
copy

SYNOPSIS

pm2 [command] [options]

DESCRIPTION

pm2 is a production process manager for Node.js applications. It keeps applications running continuously with automatic restart on crashes, built-in load balancing via cluster mode, and centralized log management.
The tool provides a monitoring dashboard (monit), process listing, log viewing, and startup script generation for system boot persistence. It can manage multiple applications simultaneously, each with independent configurations for instances, environment variables, and restart strategies.

PARAMETERS

start APP

Start application.
stop ID
Stop process.
restart ID
Restart process.
list
List processes.
logs
View logs.
monit
Monitor dashboard.
--name NAME
Process name.

CONFIGURATION

ecosystem.config.js

Application configuration file defining processes, environment variables, and deployment settings.
~/.pm2/
PM2 home directory containing logs, process database, and module data.
PM2_HOME
Environment variable to override the default PM2 home directory.

CAVEATS

Node.js specific. Requires npm install. Daemon-based.

HISTORY

PM2 was created for production Node.js process management.

SEE ALSO

node(1), forever(1), nodemon(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community