编写脚本 前面注释必须要,否则无法启动
#!/bin/sh
### BEGIN INIT INFO
# Provides: start-community.sh
# Required-start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the svnd.sh daemon
# Description: starts svnd.sh using start-stop-daemon
### END INIT INFO
export JAVA_HOME=/usr/local/programs/java/jdk1.8.0_202
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
cd /usr/local/programs/
echo "jar 包开始部署"
nohup java -Dloader.path="/usr/local/programs/community-lib" -jar /usr/local/programs/community-admin.jar --spring.profiles.active=cloud --project.client=false --server.port=8081 > /dev/null 2>&1 &
echo "ok is successful"
然后放入 /etc/init.d 目录下,添加执行权限
chmod +x start.sh