不错的linux下通用的java程序启动脚本(转载)_rodert-CSDN博客_java 启动脚本
https://blog.csdn.net/qq_40374604/article/details/91820355
Linux shell脚本启动 停止 重启jar包 - 君哥~ - 博客园
https://www.cnblogs.com/wangfajun/p/9585530.html
创建启动脚本
cd jarvim autostart.sh#!/bin/shsource /etc/profileRUN_DIR="/root/jar";nohup java -Xms512m -Xmx1024m -jar $RUN_DIR/scancode.jar >> $RUN_DIR/scancode.log 2>&1 &nohup java -Xms1024m -Xmx1024m -jar $RUN_DIR/settle-0.0.1-SNAPSHOT.jar --spring.profiles.active=local >> $RUN_DIR/settle.log 2>&1 &chmod +x ./autostart.sh
添加开机自启
vim /usr/lib/systemd/system/jar.service[Unit]Description=jarAfter=network.target[Service]Type=forkingExecStart=/root/jar/autostart.shPrivateTmp=true[Install]WantedBy=multi-user.targetchmod 755 /usr/lib/systemd/system/jar.servicesystemctl daemon-reloadsystemctl enable jar.service
关闭开机自启
systemctl disable jar.service
