1 Star 0 Fork 0

CHQ7 / JAR包注册LINUX系统应用服务解决方案

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

centos-service

介绍

JAR包注册LINUX系统应用服务解决方案

使用说明

添加执行权限

chmod +x  service.sh

移动到/etc/init.d目录下

mv service.sh /etc/init.d/

【chkconfig 开机自启 方式一】

chkconfig可以更新(启动或停止)和查询系统服务(service)运行级信息。
更简单一点,chkconfig是一个用于维护/etc/rc[0-6].d目录的命令行工具。

添加系统服务

# 注册系统服务
chkconfig --add service.sh
# 删除系统服务
chkconfig --del service.sh
# 设置开机启动
chkconfig service.sh on
# 查看系统服务列表
chkconfig --list

常用命令

#启动服务
service service.sh start
#停止服务
service service.sh stop
#重启服务
service service.sh restart
#服务状态
service service.sh status

【 systemctl 开机自启 方式二】

在Centos 中 systemctl  是设置系统服务的命令,
即 service, 它融合之前service和chkconfig的功能于一体。
可以使用它永久性或只在当前会话中启用/禁用服务。

在 /usr/lib/systemd/system/ 创建服务 demo.service

[Unit]
Description=eureka
After=network.target
  
[Service]
Type=forking
ExecStart=/etc/rc.d/init.d/server.sh start
ExecReload=/etc/rc.d/init.d/server.sh restart
ExecStop=/etc/rc.d/init.d/server.sh stop
PrivateTmp=true
  
[Install]
WantedBy=multi-user.target

常用命令

#重载系统服务:
systemctl daemon-reload
#设置开机启动
systemctl enable demo.service
#设置禁用启动
systemctl disable demo.service
#查看系统服务列表
systemctl list-unit-files –type=service
#启动服务
systemctl start demo.service
#停止服务
systemctl stop demo.service
#重启服务
systemctl reload demo.service
#服务状态
systemctl status demo.service
MIT License Copyright (c) 2021 云柒 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

JAR包注册LINUX系统应用服务解决方案 展开 收起
Shell
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/umb/centos-service.git
git@gitee.com:umb/centos-service.git
umb
centos-service
JAR包注册LINUX系统应用服务解决方案
master

搜索帮助