admin管理员组

文章数量:1130349

springboot项目linux系统设置开机启动项

先在自己电脑上新建一个txt文件,编辑成以下内容 ,编辑完后将文件编辑为   bylf-admin-start   不带后缀啊

#! /bin/sh

### BEGIN INIT INFO
# Provides:          php-fpm
# Required-Start:    $remote_fs $network
# Required-Stop:     $remote_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts php-fpm
# Description:       starts the PHP FastCGI Process Manager daemon
### END INIT INFO


#chkconfig:2345 80 05 --指定在哪几个级别执行,0一般指关机,
#6指的是重启,其他为正常启动。80为启动的优先级,05为关闭的优先机
#description:mystart service
RETVAL=0
start(){
echo -n "mystart serive ..."
cd /www/xyzby
./start.sh

}

stop(){
echo "mystart service is stoped..."
cd /www/xyzby
./stop.sh
}

case $1 in
start)
start
;;
stop)
stop
;;
esac
exit $RETVAL

比如我的

我的项目地址在

我的start.sh为服务启动脚本,stop.sh为服务停止脚本

start.sh为

#!/bin/sh
echo  "bylf-admin  启动开始............."

sleep 5s

nohup java -jar bylf-admin.jar 2>&1 > bylf-admin.out &

echo  "bylf-admin  启动成功............."

stop.sh为

#!/bin/sh

echo "bylf-admin    停止开始......."

ID=`ps -ef | grep "bylf-admin.jar" | grep -v "grep" | awk '{print $2}'`

echo $ID

for id in $ID
do

kill -9 $id

echo "killed $id"

done

sleep 5s

echo "bylf-admin    停止成功......."

 

大家可以参考下

然后在linux服务器下,依次输入

cd /etc/rc.d/rc.local

chmod +r /etc/rc.d/init.d/bylf-admin-start

chkconfig --add bylf-admin-start

chkconfig --list bylf-admin-start

 

然后重启试试就好了

 

 

springboot项目linux系统设置开机启动项

先在自己电脑上新建一个txt文件,编辑成以下内容 ,编辑完后将文件编辑为   bylf-admin-start   不带后缀啊

#! /bin/sh

### BEGIN INIT INFO
# Provides:          php-fpm
# Required-Start:    $remote_fs $network
# Required-Stop:     $remote_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts php-fpm
# Description:       starts the PHP FastCGI Process Manager daemon
### END INIT INFO


#chkconfig:2345 80 05 --指定在哪几个级别执行,0一般指关机,
#6指的是重启,其他为正常启动。80为启动的优先级,05为关闭的优先机
#description:mystart service
RETVAL=0
start(){
echo -n "mystart serive ..."
cd /www/xyzby
./start.sh

}

stop(){
echo "mystart service is stoped..."
cd /www/xyzby
./stop.sh
}

case $1 in
start)
start
;;
stop)
stop
;;
esac
exit $RETVAL

比如我的

我的项目地址在

我的start.sh为服务启动脚本,stop.sh为服务停止脚本

start.sh为

#!/bin/sh
echo  "bylf-admin  启动开始............."

sleep 5s

nohup java -jar bylf-admin.jar 2>&1 > bylf-admin.out &

echo  "bylf-admin  启动成功............."

stop.sh为

#!/bin/sh

echo "bylf-admin    停止开始......."

ID=`ps -ef | grep "bylf-admin.jar" | grep -v "grep" | awk '{print $2}'`

echo $ID

for id in $ID
do

kill -9 $id

echo "killed $id"

done

sleep 5s

echo "bylf-admin    停止成功......."

 

大家可以参考下

然后在linux服务器下,依次输入

cd /etc/rc.d/rc.local

chmod +r /etc/rc.d/init.d/bylf-admin-start

chkconfig --add bylf-admin-start

chkconfig --list bylf-admin-start

 

然后重启试试就好了

 

 

本文标签: 系统设置启动项项目SpringBootLinux