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 [-update-rc.d [-update-rc.d [-update-rc.d [-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

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.  -Path to replace /etc/init.d.  -Path to replace /etc/insserv/overrides.  -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

更多内容请长按二维码关注(更有不定期发红包活动吆^0^):
致儒先生

转载自:https://www.linuxidc.com/Linux/2016-07/133054.htm

声明: 除非转自他站(如有侵权,请联系处理)外,本文采用 BY-NC-SA 协议进行授权 | 智乐兔
转载请注明:转自《Debian开机启动管理
本文地址:https://www.zhiletu.com/archives-7602.html
关注公众号:智乐兔

赞赏

wechat pay微信赞赏alipay pay支付宝赞赏

上一篇
下一篇

相关文章

在线留言

你必须 登录后 才能留言!

在线客服
在线客服 X

售前: 点击这里给我发消息
售后: 点击这里给我发消息

智乐兔官微