Matomo Analytics

Documentation

How to make PM2 start on boot

By default, the PM2 service will not start the services that you are running on boot. This requires an additional step, luckily this step is very easy...

By default, the PM2 service will not start the services that you are running on boot. This requires an additional step, luckily this step is very easy.

First, run every service you want with PM2 so you're sure all the services you want to be started up on reboot, are started.

Next, run the following command:

pm2 startup

This will give the output like following:

[PM2] Init System found: systemd
[PM2] To setup the Startup Script, copy/paste the following command:
sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u ploi --hp /home/ploi

Next, run that sudo command in your terminal (this will ask for your sudo password):

sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u ploi --hp /home/ploi

After this, PM2's services that have been spawned will be started again upon reboot.

Dennis Smink

Written by Dennis Smink

Dennis brings over 13 years of hands-on experience in server management, specializing in optimizing web services for scalability and security.

Ready to dive in?
Start your free trial today.

Create an account and enjoy your 5-day free trial — no credit card required.

Start your free trial