1.创建 /etc/systemd/system目录下创建 tender.service文件
cd /etc/systemd/system
vim tender.service
2.在tender.service文件中输入以下内容
[Unit]
Description=tender
After=syslog.target network.target
[Service]
WorkingDirectory=/opt/Dtech/Web
##jdk路径 以及启动jar文件命令
ExecStart= /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -jar /opt/Dtech/Web/tender.jar
SuccessExitStatus=143
TimeoutStopSec=10
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
3.设置为开机自启动服务
3.1 启动程序
systemctl start tender
3.2 查看启动状态
systemctl status tender
![成功](https://i-blog.csdnimg.cn/blog_migrate/8d4834366eddf43a1b2a30e0f4215155.png#pic_center)
3.3 添加到自启
systemctl enable tender
![成功后显示](https://i-blog.csdnimg.cn/blog_migrate/dc3af4d5cfba5c6ca649d5119c5ab153.jpeg#pic_center)