75

I am using pm2 to manage my node.js processes. Very happy with it so far.

What is the purpose of $ pm2 save? What is the purpose of saving a process list? I don't quite understand from the documentation. https://github.com/Unitech/pm2

guagay_wk
  • 26,337
  • 54
  • 186
  • 295

2 Answers2

173

pm2 save takes a snapshot of your currently running Node applications. You can then restore these applications using pm2 resurrect.

This is useful because it means you don't have to manually restart each application when you restart pm2 (such as a machine reboot). Instead, you can just have a script that calls pm2 resurrect and it'll start up all the Node apps.

pm2 resurrect is useful to be called manually. If you want your processes to automatically start on boot, you should create a startup script with pm2 startup.

João Pimentel Ferreira
  • 14,289
  • 10
  • 80
  • 109
Rowan Freeman
  • 15,724
  • 11
  • 69
  • 100
  • 9
    Note `pm2 resurrect` is useful to be called manually. If you want your processes to automatically start on boot, you should create a startup script with `pm2 startup`. More info here: http://pm2.keymetrics.io/docs/usage/startup/ – maganap Nov 30 '18 at 11:05
  • if we have multiple application running. Do you know in what order after running resurrect? I have not been able to find out in any documentation – Pritish Jain Dec 02 '20 at 04:18
  • save is hidden behind dump if you are looking for it in the help – Gerry Mar 06 '22 at 16:35
  • The term "snapshot" is misleading and makes you overthink on what it does. PM2 simply describes it as "[save the app list](https://pm2.keymetrics.io/docs/usage/startup/#saving-the-app-list-to-be-restored-at-reboot)". – Philip Borbon Jan 04 '23 at 16:27
16

$ pm2 save is used to save the pm2 process list to relaunch them after a server reboot. It comes generaly with :

pm2 startup which generates Startup Script

Badr Bellaj
  • 11,560
  • 2
  • 43
  • 44