debian开机启动管理(转文)

linux下,services的启动、停止等通常是通过/etc/init.d的目录下的脚本来控制的。
在启动或改变运行级别是在/etc/rcX.d中来搜索脚本。其中X是运行级别。

比如Apache2,安装完成后,默认或启动。比如我安装了vagrant的LMPA的box。需要禁止掉自启动,就需要禁止掉这个服务,然后在需要的时候使用

/usr/sbin/apachectl start     #/etc/init.d/apache2 start 

在debian中使用 update-rc.d命令来实现

   update-rc.d [-n] [-f] <basename> remove
update-rc.d [-n] <basename> defaults [NN | SS KK]
update-rc.d [-n] <basename> start|stop NN runlvl [runlvl] [...] .
update-rc.d [-n] <basename> disable|enable [S|2|3|4|5]
-n: not really
-f: force
  1. 删除服务

    update-rc.d -f apache2 remove # -f 为强制删除

  2. 添加服务

    update-rc.d apache2 defaults

并且可以指定该服务的启动顺序:

update-rc.d apache2 defaults 90

还可以更详细的控制start与kill顺序:

update-rc.d apache2 defaults 20 80

其中前面的20是start时的运行顺序级别,80为kill时的级别。也可以写成:

update-rc.d apache2 start 20 2 3 4 5 . stop 80 0 1 6 .

其中0~6为运行级别。 update-rc.d命令不仅适用Linux服务,编写的脚本同样可以用这个命令设为开机自动运行

在debian6中使用update-rc.d会报错,如下:

  update-rc.d: using dependency based boot sequencing

可以使用 insserv 命令来代替 update-rc.d

insserv [<options>] [init_script|init_directory]
Available options:
-h, --help This help.
-r, --remove Remove the listed scripts from all runlevels.
-f, --force Ignore if a required service is missed.
-v, --verbose Provide information on what is being done.
-p <path>, --path <path> Path to replace /etc/init.d.
-o <path>, --override <path> Path to replace /etc/insserv/overrides.
-c <config>, --config <config> Path to config file.
-n, --dryrun Do not change the system, only talk about it.
-d, --default Use default runlevels a defined in the scripts

比如
insserv -r apache2

debian开机启动管理的更多相关文章

  1. 【转】Linux开机启动管理---systemd使用

    常用命令  使某服务自动启动 systemctl enable httpd.service 使某服务不自动启动 systemctl disable httpd.service 检查服务状态 syste ...

  2. CentOS7开机启动管理systemd简介及使用

    systemd提供更优秀的框架以表示系统服务间的依赖关系实现系统初始化时服务的并行启动,同时达到降低Shell的系统开销的效果systemd的目标是:尽可能启动更少进程:尽可能将更多进程并行启动.sy ...

  3. (十八)Linux开机启动管理---systemd使用

    常用命令 使某服务自动启动 systemctl enable httpd.service 使某服务不自动启动 systemctl disable httpd.service 检查服务状态 system ...

  4. centos7 开机启动管理

    查看开机启动项 ls /etc/systemd/system/multi-user.target.wants/ 设置开机启动 systemctl enable mongodb.service

  5. (转)CentOS下开机启动查看管理命令:chkconfig用法

    CentOS下开机启动查看管理命令:chkconfig用法   CentOS下开机启动查看管理的命令是:chkconfig   1. 开机启动列表查看: chkconfig --list     说明 ...

  6. Debian - 设置MYSQL开机启动

    设置MYSQL 首先拷贝mysql.server到/etc/init.d目录下命名为mysql # cp /自己的安装目录/mysql/share/mysql/mysql.server /etc/in ...

  7. Centos7.x:开机启动服务的配置和管理

    一.开机启动服务的配置 1.创建服务配置(权限754) vim /usr/lib/systemd/system/nginx.service 文件内容解释 [Unit]:服务的说明Description ...

  8. Virtualbox开机启动,service命令管理

    #!/bin/bash#chkconfig:235 80 20#description:start or stop vbox#Author:Qty~20180502#OS:RedHatEnterpri ...

  9. debian 9 开机启动

    由于某些软件并没有增加开启启动的服务,很多时候需要手工添加,一般我们都是推荐添加命令到 /etc/rc.local 文件,但是 Debian 9 默认不带 /etc/rc.local 文件,而 rc. ...

随机推荐

  1. Asp.Net alert 方法

    public static void ExcuteAlert(Page page, string strAlerts)        {            ClientScriptManager  ...

  2. CEUtils---我在Unity中使用的一些小类库(不断更新中)

    项目地址: http://git.oschina.net/eran/CEUtils

  3. 我去,徒弟半夜来电让写一个PHP短信验证(和群发)

    感觉很纳闷啊,,..好几天几乎通宵了,今晚本来以为有个早觉睡,居然2点多才打电话来让帮忙... 记得前段时间还有博友问过同类的问题.... 名字我就隐藏掉了,呵呵,, 我在网上随便找了一个提供相应接口 ...

  4. Proteus 8 画原理图仿真 1602 LCD显示字符

    以下是源程序: #include <reg52.h> #include<intrins.h> /** * P2 上接的是 D1 ~ D7 */ sbit RS = P3 ^ ; ...

  5. [转]SOCKET通信中TCP、UDP数据包大小的确定

    TCP.UDP数据包大小的确定 UDP和TCP协议利用端口号实现多项应用同时发送和接收数据.数据通过源端口发送出去,通过目标端口接收.有的网络应用只能使用预留或注册的静态端口:而另外一些网络应用则可以 ...

  6. 规则引擎以及blaze 规则库的集成初探之三——Blaze规则引擎和SRL

    原文地址:http://jefferson.iteye.com/blog/68604 在上面介绍利用JSR94的api使用的章节中,我们使用的具体引擎的实现是一个商业产品,如果想了解Drools的使用 ...

  7. 有向图的强连通分量——Tarjan

    在同一个DFS树中分离不同的强连通分量SCC; 考虑一个强连通分量C,设第一个被发现的点是 x,希望在 x 访问完时立刻输出 C,这样就可以实现 在同一个DFS树中分离不同的强连通分量了. 问题就转换 ...

  8. 使用异步js解决模态窗口切换的办法

    核心代码 js ="setTimeout(function(){document.getElementsByTagName('Button')[3].click()},100);" ...

  9. zoj 3673 1729

    1729 Time Limit: 3 Seconds      Memory Limit: 65536 KB 1729 is the natural number following 1728 and ...

  10. 17-underscore库(下)

    一.函数介绍 1.bind 结构 _.bind(function, object, *arguments) 说明 一个对象中所有的成员函数的this都指向这个对象 举例 _.bind(function ...