转自:https://www.cnblogs.com/EasonJim/p/7168216.html

在Debian8中systemd和sysVinit同时存在,NTP就是在/etc/init.d/ntp中启动

首先了解以下Ubuntu运行级别(init)对应工具的变化历史:

1、Ubuntu 6.10及以前版本使用Sysvinit。

2、Ubuntu 14.10及以前版本使用Upstart但是还留着Sysvinit并存。

https://wiki.ubuntu.com/Upstart

https://help.ubuntu.com/community/UpstartHowto

3、Ubuntu 15.04开始预设使用Systemd,但是可以在开机选项选择使用Systemd或Upstart,但是不可同時使用Sysvinit或Upstart并存。

https://wiki.ubuntu.com/SystemdForUpstartUsers

整个Linux的init发展历史:

https://zh.wikipedia.org/wiki/Init

详细介绍三个体系:Sysvinit、Upstart、Systemd

Sysvinit:https://www.ibm.com/developerworks/cn/linux/1407_liuming_init1/index.html

Upstart:https://www.ibm.com/developerworks/cn/linux/1407_liuming_init2/index.html

Systemd:https://www.ibm.com/developerworks/cn/linux/1407_liuming_init3/index.html

总结Sysvinit:

对于其它两项在Ubuntu上已经有介绍其使用方法,主要是Sysvinit比较历史悠久,其主要就是一个Shell脚本,并且是放置在/etc/init.d文件夹下。然后通过update-rc.d命令进行运行级别的操作来达到服务的启动。下面是一些服务脚本的编写参考:

其实系统提供的说明文档,在/etc/init.d/README

https://gist.github.com/naholyr/4275302

https://www.cyberciti.biz/tips/linux-write-sys-v-init-script-to-start-stop-service.html

来自:stackexchange的回答

chaos' answer is what some documentation says. But it's not what systemd actually does. (It's not what van Smoorenburg rc did, either. The van Smoorenburg rc most definitely did not ignore LSB headers, which insserv used to calculate static orderings, for starters.) The Freedesktop documentation, such as that "Incompatibilities" page, is in fact wrong, on these and other points. (The HOME environment variable in fact is often set, for example. This went wholly undocumented anywhere for a long time. It's now documented in the manual, at least, but that Freedesktop WWW page still hasn't been corrected.)

The native service format for systemd is the service unit. systemd's service management proper operates solely in terms of those, which it reads from one of nine directories where (system-wide) .service files can live. /etc/systemd/system/run/systemd/system/usr/local/lib/systemd/system, and /usr/lib/systemd/system are four of those directories.

The compatibility with van Smoorenburg rc scripts is achieved with a conversion program, named systemd-sysv-generator. This program is listed in the /usr/lib/systemd/system-generators/directory and is thus run automatically by systemd early in the bootstrap process at every boot, and again every time that systemd is instructed to re-load its configuration later on.

This program is a generator, a type of ancillary utility whose job is to create service unit files on the fly, in a tmpfs where three more of those nine directories (which are intended to be used only by generators) are located. systemd-sysv-generator generates the service units that run the van Smoorenburg rc scripts from /etc/init.d, if it doesn't find a native systemd service unit by that name already existing in the other six locations.

systemd service management only knows about service units. These automatically (re-)generated service units are written to invoke the van Smoorenburg rc scripts. They have, amongst other things:

[Unit]
SourcePath=/etc/init.d/wibble
[Service]
ExecStart=/etc/init.d/wibble start
ExecStop=/etc/init.d/wibble stop

Received wisdom is that the van Smoorenburg rc scripts must have an LSB header, and are run in parallel without honouring the priorities imposed by the /etc/rc?.d/ system. This is incorrect on all points.

In fact, they don't need to have an LSB header, and if they do not systemd-sysv-generator can recognize the more limited old RedHat comment headers (description:pidfile:, and so forth). Moreover, in the absence of an LSB header it will fall back to the contents of the /etc/rc?.dsymbolic link farms, reading the priorities encoded into the link names and constructing a before/after ordering from them, serializing the services. Not only are LSB headers not a requirement, and not only do they themselves encode before/after orderings that serialize things to an extent, the fallback behaviour in their complete absence is actually significantly non-parallelized operation.

The reason that /etc/rc3.d didn't appear to matter is that you probably had that script enabled via another /etc/rc?.d/ directory. systemd-sysv-generator translates being listed in any of /etc/rc2.d//etc/rc3.d/, and /etc/rc4.d/ into a native Wanted-By relationship to systemd's multi-user.target. Run levels are "obsolete" in the systemd world, and you can forget about them.

[Linux]systemd和sysV的更多相关文章

  1. [转帖][Linux]systemd和sysV

    [Linux]systemd和sysV   转自:https://www.cnblogs.com/EasonJim/p/7168216.html 在Debian8中systemd和sysVinit同时 ...

  2. Linux systemd 打开调试终端、添加开机自运行程序

    /************************************************************************* * Linux systemd 打开调试终端.添加 ...

  3. Linux Systemd——在RHEL/CentOS 7中启动/停止/重启服务

    RHEL/CentOS 7.0中一个最主要的改变,就是切换到了systemd.它用于替代红帽企业版Linux前任版本中的SysV和Upstart,对系统和服务进行管理.systemd兼容SysV和Li ...

  4. Linux systemd资源控制初探

    Linux systemd资源控制初探 本文记录一次cgroup子目录丢失问题,并简单探索了Linux systemd的资源控制机制. 问题现象 我们希望通过systemd拉起服务并通过cgroup限 ...

  5. linux systemd 从简单的例子入门

    linux systemd 从简单的例子入门 网上很多相关链接,一上来就给一大堆命令和讲解,让人头都大. 我们希望有一个service(服务),让它在开机启动的时候就执行. 用 root 登陆以后: ...

  6. [转帖]Linux systemd 常用命令

    Linux systemd 常用命令 https://www.cnblogs.com/tsdxdx/p/7288490.html systemctl hostnamectl timedatectl l ...

  7. linux systemd详解

    CentOS 7 使用systemd替换了SysV.Systemd目的是要取代Unix时代以来一直在使用的init系统,兼容SysV和LSB的启动脚本,而且够在进程启动过程中更有效地引导加载服务. s ...

  8. Linux Systemd 详细介绍: Unit、Unit File、Systemctl、Target

    Systemd 简介 CentOS 7 使用 Systemd 替换了SysV Ubuntu 从 15.04 开始使用 Systemd Systemd 是 Linux 系统工具,用来启动守护进程,已成为 ...

  9. 【转发】CentOS 7 巨大变动之 systemd 取代 SysV的Init

    1 systemd是什么 首先systmed是一个用户空间的程序,属于应用程序,不属于Linux内核范畴,Linux内核的主要特征在所有发行版中是统一的,厂商可以自由改变的是用户空间的应用程序.   ...

随机推荐

  1. Redis自学笔记:3.5入门-集合类型

    3.5集合类型 3.5.1介绍 在集合中的每个元素都是不同的,且没有顺序 表3-4集合类型和列表类型的对比 - 集合类型 列表类型 存储内容 至多232-1个字符串 至多232-1个字符串 有序性 否 ...

  2. go 单元测试时读取配置文件

    在go项目中读取配置文件时,如果使用的是相对路径,在执行run test时也会在test文件所在的目录下去读取配置文件,如果文件没在此目录下会报错:“open env1.json: The syste ...

  3. Sunday串匹配算法 C语言实现

    unsigned char * sunday( void * a_buf1, unsigned int len1, void * a_buf2, unsigned int len2 ){ unsign ...

  4. ArrayList源码分析和实例应用

    1.ArrayList介绍 ArrayList 是一个数组队列,相当于 动态数组.与Java中的数组相比,它的容量能动态增长.它继承于AbstractList,实现了List, RandomAcces ...

  5. 关于js函数对象的理解

    js中函数和对象的关系: 什么是对象?根据W3C上面的解释JS中所有事物都是对象,对象是拥有属性和方法的数据,由此可以看出除了基 本值类型不是对象(number.string.Boolean.Unde ...

  6. list utilities监视数据库前滚操作

    您可以使用 db2pd 或 LIST UTILITIES 命令来监视数据库前滚操作的进度. 过程 发出 LIST UTILITIES 命令并指定 SHOW DETAIL 参数 db2 LIST UTI ...

  7. 【转】Java基础:System.out.println与System.err.println的区别

    同时使用了System.out.println与System.err.println()打印输入内容,结果看到的内容和预想的不一样,顺序与预料的不同并不是因为err和out的区别导致,而是因为他们是两 ...

  8. python之函数第二篇

    一.名称空间与作用域 名称空间分类: 内置名称空间 import this dir(buil-in) 查看全部内置 全局名称空间 局部名称空间 在函数体内等 查询全局和局部 globals()方法可以 ...

  9. 【数论&想法题】小C的问题 @"科林明伦杯"哈尔滨理工大学第八届程序设计竞赛

    Time Limit: 1000 MS Memory Limit: 256000 K Description 小C是一个可爱的女孩,她特别喜欢世界上最稳定的图形:三角形.有一天她得到了n根木棍,她把这 ...

  10. pygame 笔记-5 模块化&加入敌人

    上一节,已经用OOP方法,把几个类抽象出来了,但是都集中在一个.py文件中,代码显得很冗长,这一节复用模块化的思想,把这个大文件拆分成几个小文件: 先把主角Player单独放到一个文件player.p ...