提示: 此方法是centos7下的配置方法
1、/ets/systemd/system下新建文件 example.service
2、编辑文件内容
[Unit]
Description=example #描述
After=syslog.target network.target #依赖
[Service]
Type=simple
ExecStart=/usr/bin/java -jar /www/service/example.jar
#前面是java命令的绝对路径 后面是jar包的绝对路径
ExecStop=/bin/kill -15 $MAINPID
User=root
Group=root
[Install]
WantedBy=multi-user.target #启动等级
3、使用命令
systemctl start example 或 systemctl start example.service
配置改变后:
systemctl daemon-reload
systemctl start sell.service
停止服务:
systemctl stop example 或 systemctl stop example.service
开机启动:
systemctl enable example 或 systemctl enable example.service
禁止开机启动:
systemctl disable example 或 systemctl disable example.service
尊重作者,转载请注明出处!
版权申明:本文版权归作者所有,未经授权,任何单位或个人不得以任何形式转载、摘编或利用其它方式使用本博客内容。作者保留追究相关法律责任的权利。如需使用博客内容,请与作者联系获得授权。感谢对本文的尊重与支持。
免责声明:本网站所载内容仅供参考,不构成任何专业建议。用户基于本网站内容作出的决策,风险自担。对于因使用本网站内容而产生的任何直接或间接损失,本网站不承担任何责任。请用户审慎判断,理性使用。