How to create a Profitrailer VPS startup script for Ubuntu

darmou(26)
Published in
#ub
Words
61
Reading
1 min
Listen
Play
9y

There are several ways of adding a script on startup, however one of the easiest is to alter the /etc/rc.local script in Ubuntu.

We can provide a startup script in /usr/local/bin called profittrailer_start.sh

#!/bin/sh
# 0 is the id for profit trailer for me pm2 status will show which id you have
/usr/local/bin/pm2 restart 0 
# 1 is the id for profit trailer feeder
/usr/local/bin/pm2 restart 1
sudo chmod +x /usr/local/bin/profittrailer_start.sh
sudo chmod 755 /usr/local/bin/profittrailer_start.sh

Next, update your /etc/rc.local script with full path and name of your created script after the sh command

#!/bin/sh -e
#Ensure the above line is at the top
sh '/usr/local/bin/profittrailer_start.sh'

# Remember to put the line below at the end
exit 0

Then make rc.local executable

sudo chown root /etc/rc.local
sudo chmod 755 /etc/rc.local

Check everything works fine by executing

sudo /etc/init.d/rc.local start

Test restart your system.