1、增加/lib/systemd/system/springweb.service内容
- [Unit]
- Description=springweb
- After=network.target
-
- [Service]
- Type=simple
- ExecStart=/usr/bin/java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -jar /data/user/scm/jenkins/workspace/springweb/target/web-0.0.1-SNAPSHOT.jar
- ExecReload=/bin/kill -s HUP $MAINPID
- ExecStop=/bin/kill -s QUIT $MAINPID
- User=root
-
- [Install]
- WantedBy=multi-user.target
-
- 或者
- [Unit]
- Description=springweb
-
- [Service]
- Type=simple
- Restart=always
- PrivateTmp=true
- ExecStart=/usr/bin/java -jar /data/user/web-0.0.1-SNAPSHOT.jar
- ExecStop=/bin/kill -15 $MAINPID
- User=root
- SuccessExitStatus=143
-
- [Install]
- WantedBy=multi-user.target
2、操作服务
//重载服务systemctl daemon-reload
//查看service状态: systemctl status springweb
//配置开机启动: systemctl enable springweb
//启动springweb: systemctl start springweb
//停止springweb: systemctl stop springweb
//重启springweb: systemctl restart springweb