$ pm2 start app.js # Launch the app.js app
$ pm2 start app.js -i 4 Start 4 app.js application instances in cluster mode
# 4 applications will automatically load balance
$ pm2 start app.js --name="api" # Launch the application and name it "API"
$ pm2 start app.js --watch Automatically restart the application when the file changes
$ pm2 start script.sh Start the bash script

$ pm2 list List all applications that PM2 started
$ pm2 monit Display the CPU and memory usage for each application
$ pm2 show [app-name] Display all information about the application

$ pm2 logs Display logs for all applications
$ pm2 logs [app-name] # display logs for the specified application
pm2 flush

$ pm2 stop all # Stop all apps
$ pm2 stop 0 # stop the specified application with id 0
$ pm2 restart all # Restart all applications
$ pm2 reload all Restart all applications in cluster mode
$ pm2 gracefulReload all # Graceful reload all apps in cluster mode
$ pm2 delete all # Close and delete all apps
$ pm2 delete 0 # delete app id 0
$ pm2 scale api 10 # Extend the application named API to 10 instances
$ pm2 reset [app-name] Reset the number of restarts

$ pm2 startup Create a boot autostart command
$ pm2 save Save the list of current apps
$ pm2 resurrect Reload the list of saved apps
$ pm2 update # Save processes, kill PM2 and restore processes
$ pm2 generate # Generate a sample json configuration file
pm2 start app.js --node-args="--max-old-space-size=1024"

Copy the code

Reference: Common PM2 commands