版权声明:转载请附此链接 https://blog.csdn.net/qq_42393859/article/details/88170761
1、新建个shell脚本文件(例starter.sh)
内容如下
#!/bin/sh
### BEGIN INIT INFO
# Provides: starter
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start starter
# Description: start starter
### END INIT INFO
sudo -u hitachi sh /home/hitachi/hbis-workspace/apache_tomcat_v2/bin/startup.sh
cd /home/hitachi/hbis-workspace/node-v9.9.0-linux-x64/bin/
sudo -u hitachi & node /home/hitachi/hcrd/project/Realtime_Multi-Person_Pose_Estimation-show/testing/python/test1.js&
sudo -u hitachi & node /home/hitachi/hcrd/project/Realtime_Multi-Person_Pose_Estimation-show/testing/python/test2.js
exit 0
其中starter是你的脚本文件名,
### END INIT INFO下是你要写的shell脚本,然后需要开机自启的
2、设置权限
sudo chmod 755 starter.sh
3、把脚本放到启动目录下
sudo mv starter.sh /etc/init.d/
4、将脚本添加到启动脚本
cd /etc/init.d/
sudo update-rc.d starter.sh defaults 90
后面90数字是你设置的启动序号,越大级别越低,执行越晚
ps:如果想要移除开机自启脚本
sudo update-rc.d -f starter.sh remove