linux中daemon的改动之systemctl替代chkconfig和service
来源:互联网 发布:2016年7月中国经济数据 编辑:程序博客网 时间:2024/06/03 16:59
为了顺应时间的发展,这里总结下。在目前很多linux的新发行版本里,系统对于daemon的启动管理方法不再采用SystemV形式,而是使用了sytemd的架构来管理daemon的启动。
一、runlevel 到 target的改变
在systemd的管理体系里面,以前的运行级别(runlevel)的概念被新的运行目标(target)所取代。tartget的命名类似于multi-user.target等这种形式,比如原来的运行级别3(runlevel3)就对应新的多用户目标(multi-user.target),run level 5就相当于graphical.target。
由于不再使用runlevle概念,所以/etc/inittab也不再被系统使用 --- 无怪乎在新版本ubuntu上找不到inittab文件了。
而在systemd的管理体系里面,默认的target(相当于以前的默认运行级别)是通过软链来实现。如:
ln -s /lib/systemd/system/runlevel3.target /etc/systemd/system/default.target
在/lib/systemd/system/ 下面定义runlevelX.target文件目的主要是为了能够兼容以前的运行级别level的管理方法。 事实上/lib/systemd/system/runlevel3.target,同样是被软连接到multi-user.target。
注:opensuse下是在/usr/lib/systemd/system/目录下。
systemctl status httpd.service (服务详细信息)
systemctl is-active httpd.service (仅显示是否 Active)
加入自定义服务chkconfig --add testsystemctl load test.service删除服务chkconfig --del xxx停掉应用,删除相应的配置文件显示所有已启动的服务chkconfig --listsystemctl list-units --type=service启动某服务service httpd startsystemctl start httpd.service停止某服务service httpd stopsystemctl stop httpd.service重启某服务service httpd restartsystemctl restart httpd.service注:systemctl后的服务名可以到/usr/lib/systemd/system目录查看(opensuse下),其他发行版是位于/lib/systemd/system/ 下。
二,配置文件与自启动
还以上面提到的httpd.service配置为例,httpd.service文件里可以找到如下行:
[Install]
WantedBy=multi-user.target
则表明在多用户目标(multi-user.target,相当于level3)时自动启动。如果想在runlevel 5下也自启动,则可以将配置改为如下:
[Install]
WantedBy=multi-user.target graphical.target
一旦设定了自动启动(enbale),就在/etc/systemd/system/.wants/下面建了一个httpd.service的软连接,连接到/lib/systemd/system/下的相应服务那里 。所以显示自动启动状态的unit (类似于chekconfig --list命令的结果),可以通过下面的方法:
#ls /etc/systemd/system/multi-user.target.wants/
- linux中daemon的改动之systemctl替代chkconfig和service
- Linux中systemctl替代service与chkconfig
- linux中service与chkconfig的替代者systemctl
- linux中service与chkconfig的替代者systemctl
- linux中service与chkconfig的替代者systemctl
- linux中service与chkconfig的替代者systemctl的简单介绍
- linux中service与chkconfig的替代者systemctl的简单介绍
- RHEL 7 中 systemctl 的用法(替代service 和 chkconfig)
- RHEL 7 中 systemctl 的用法(替代service 和 chkconfig)
- systemctl替代service与chkconfig
- linux中service与chkconfig的替代…
- Centos7下的systemctl命令与service和chkconfig
- Centos7下的systemctl命令与service和chkconfig
- Centos7下的systemctl命令与service和chkconfig
- 更新换代----systemctl命令取代chkconfig和service
- systemctl-chkconfig-service
- linux命令之service和chkconfig
- centos7 systemctl取代service和chkconfig来实现系统管理
- java基础知识(五)java内存模型和volatile关键字
- Reactjs开发自制编程语言Monkey的编译器:高能技术干货之语法高亮2
- Maven学习笔记
- Unity 导入下载音效出错
- mysql 取每个分组中时间最近的记录
- linux中daemon的改动之systemctl替代chkconfig和service
- 每日英语好文翻译2
- java :文件和byte数组转换
- [Android]查看代码混淆后的日志
- Java中 outer 标签的使用
- 通过java调用Http接口上传图片到服务器
- Oracle存储过程基本语法介绍
- django+spider简易爬虫搭建
- Parameter 'id' not found. Available parameters are [0, 1, 2, param3, param1, param2]