Centos7 sets the java backend project to start automatically at boot [script, self-start at boot]

1.Switch directory

cd /etc/init.d/

Insert image description here

2. Edit the script

vim wbs-service-start.sh

Edit content

#!/bin/bash
# chkconfig: 2345 80 90
# description: auto_run

nohup java -jar /usr/java/wbs-service.jar > /dev/null 2>&1 &
echo $! > /var/run/wbs-service.pid

Insert image description here

3. Add entry system service

systemctl enable wbs-service-start.sh

Insert image description here

4. Edit service files

/etc/systemd/system/Create the same name in the directory*.service

[Unit]
Description=Auto Start Java springboot Pojoect

[Service]
User=root
ExecStart=/bin/bash /etc/init.d/web-service-start.sh
SuccessExitStatus=143

[Install]
WantedBy=multi-user.target

5. Start the service

systemctl enable web-service-start.service

Insert image description here

Guess you like

Origin blog.csdn.net/qq_22841387/article/details/131363025