Linux 开启java守护进程
2023-12-28 本文已影响0人
夜空最亮的9星
#!/bin/bash
cat >/tmp/blbs.service <<EOL
[Unit]
Description=Open Java blbs Service
After=network.target
[Service]
Type=simple
User=root
Restart=on-failure
RestartSec=5s
ExecStart=/opt/jdk1.8.0_281/bin/java -jar /app/bl_jar/ruoyi-blbs.jar --spring.profiles.active=node1
ExecStop=/usr/bin/kill -15 $MAINPID
WorkingDirectory=/app/bl_jar
[Install]
WantedBy=multi-user.target
EOL
sudo mv /tmp/blbs.service /lib/systemd/system/blbs.service
echo "[*] Starting blbs systemd service"
sudo systemctl daemon-reload
sudo systemctl enable blbs.service
sudo systemctl is-enabled blbs.service
sudo systemctl restart blbs.service
#sudo systemctl start blbs.service
sudo systemctl status blbs.service