PM2 Process Manager Commands
PM2 is a powerful, production-grade Node.js process manager that helps you keep your applications alive indefinitely, reload them without downtime, and manage their lifecycle. This page provides a quick reference for essential PM2 commands to streamline your application management.
PM2 Start Commands
Initiate your Node.js applications using PM2 with various options for flexibility and scalability.
##############################################################################
# PM2 Start Commands
##############################################################################
# Start commands
pm2 start <file> # Start an application
pm2 start <app_id> # Start a stopped application
pm2 start <app_id> ecosystem.config.js # Start an app with the configuration in ecosystem file
pm2 start <file> -i <number_of_instances> # Start an app in cluster mode with n duplicated instances
PM2 Management Commands
Control the lifecycle of your applications, save configurations, and maintain your process list.
##############################################################################
# PM2 Management Commands
##############################################################################
# Management commands
pm2 ls # List all processes
pm2 save # Save process list to respawn at reboot
pm2 restart <app_id> # Restart an app by ID
pm2 reload <app_id> # Reload an app by ID
pm2 stop <app_id> # Stop an app by ID
pm2 stop all # Stop all running instances
pm2 delete <app_id> # Delete an app by ID
pm2 delete all # Delete all instances
pm2 ecosystem # Generate a sample ecosystem.config.js file
PM2 Monitoring Commands
Keep an eye on your applications' performance, logs, and environment variables to ensure smooth operation.
##############################################################################
# PM2 Monitoring Commands
##############################################################################
# Monitoring
pm2 show <app_id> # Show a specific app's description
pm2 logs <app_id> --lines=<number_of_lines> # Show the last n lines of logs of an app
pm2 env <app_id> # Show all environment variables of an app
pm2 monit # Monitor all applications' logs, metrics,etc