79

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

1
  • 2
    Doing this will save the process list with their current environment into the dump file $PM2_HOME/.pm2/dump.pm2 Mar 9, 2016 at 5:39

2 Answers 2

185

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.

5
  • 10
    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: pm2.keymetrics.io/docs/usage/startup
    – maganap
    Nov 30, 2018 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 Dec 2, 2020 at 4:18
  • save is hidden behind dump if you are looking for it in the help
    – Gerry
    Mar 6, 2022 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". Jan 4 at 16:27
  • Note: pm2 save dumps the list of running apps to ~/pm2/dump.pm2, and the script generated by pm2 startup uses it to run the apps when the server is rebooted.
    – Nickolay
    Oct 7 at 19:39
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.