研究出来了通过 /etc/rc.local -> /root/autostart.sh 自启动的方法

This commit is contained in:
luk.lu
2019-10-09 13:26:39 +08:00
parent 68b8fced7c
commit c0d8243ba7
3 changed files with 6 additions and 5 deletions

View File

@@ -35,11 +35,11 @@ sed -i "s/^PermitRootLogin yes/#PermitRootLogin yes/g" /etc/ssh/sshd_config
service sshd restart
echo ">>> set autostart"
mv /etc/rc.local /etc/rc.local.backup
touch /etc/rc.local
chmod +x /etc/rc.local
echo "#!/bin/bash"
echo "exec /root/autostart.sh"
echo "exit 0"
echo '#!/bin/bash' > /etc/local # can't omit, otherwise you can't launch pm2 in autostart.sh. Don't use double quote here, otherwise error.
echo 'source /root/autostart.sh' >> /etc/rc.local # make sure to sudo pm2 in autostart.sh, otherwise pm2 list can't find it as root.
touch /root/autostart.sh
chmod +x /root/autostart.sh