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. wampserver-----------如何设置wampserver在windows下开机自动启动。

    虽然很简单,但是还是做个记录.我的习惯,还是看图: 到你电脑的服务里面找到这两项然后点击右键属性,设置为自动.

  2. 使用NetBeans搭建基于Spring框架的Web应用

    NetBeans下载链接:https://netbeans.org/. 第一步:选择“文件”菜单下的“新建项目”: 第二步:类别选择“Java Web”,项目选择“Web应用程序”,单击“下一步”: ...

  3. 利用jquery获取html中被选中的input的值

    单个按钮 <div id="wrap"> <input type="radio" name="payMethod" val ...

  4. css布局之左侧固定右侧自适应布局

    参考代码如下: <form id="form1" style="height:100%; overflow:hidden;"> <div st ...

  5. busybox-1.12.2编译提示“混合的隐含和普通规则”错误解决

    编译环境:CentOs 7.1 Ubuntu 12.0.4 都可以 交叉编译工具:gcc -4.3.2 (博创6410平台) 问题描述:执行make menuconfig命令的时候,提示Makefil ...

  6. 导入maven工程遇见的问题【问题】

    原工程是一个基于websocket的maven工程(源工程:http://www.cnblogs.com/xdp-gacl/p/5193279.html),把工程导入eclipse后报错.

  7. tomcat部署https

    在server.xml配置文件中增加证书位置跟密码: <Connector port="443" protocol="org.apache.coyote.http1 ...

  8. TextBox

    一.聚焦: private void FrmOnlineChargeMoney_Paint(object sender, PaintEventArgs e) { edtAuthCode.SelectA ...

  9. CI 框架访问 http://[::1]/yourproject/

    Chances are you have left the base url blank/* |---------------------------------------------------- ...

  10. pickle与shelve

    pickle Example 写入文件 import pickle integers = [1, 2, 3, 4, 5] with open('pickle-example.p', 'wb') as ...