I have installed pm2 on my ubuntu machine.
which pm2 /usr/local/bin/pm2
This is the shell script to execute inside jenkins workspace.