cheatsheets

pm2 Cheatsheet

# list of running services
pm2 ls

# start an application
pm2 start app.js

# start with a custom name
pm2 start app.js --name my-app

# start and watch for file changes
pm2 start app.js --watch

# restart service with id=0
pm2 restart 0

# restart service by name
pm2 restart my-app

# restart all services
pm2 restart all

# stop service with id=0
pm2 stop 0

# stop all services
pm2 stop all

# delete service from pm2 list
pm2 delete 0

# display logs of service with id=7
pm2 logs 7

# display logs for all services
pm2 logs

# display logs (last 200 lines)
pm2 logs --lines 200

# display real-time monitoring dashboard
pm2 monit

# display detailed info about a service
pm2 show 0

# save current process list (to restore on reboot)
pm2 save

# restore saved process list
pm2 resurrect

# configure pm2 to start on system boot
pm2 startup

# reload all services with zero downtime (for cluster mode)
pm2 reload all