原 Debian设置开机自动启动与关闭
熟悉debian系统的应该经常会用到update-rc.d这个命令,它与redhat里的chkconfig 是相似的管理服务的工具,首先来看下这个命令的使用方法:
|
1
2
3
4
5
6
|
root@10.1.1.200:etc# update-rc.d --helpusage: 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] [...] . -n: not really -f: force |
命令 功能
update-rc.d -f <service> remove 从所有的运行级别配置目录中是删除指定的服务
update-rc.d <service> start <order> <runlevels> 配置服务在运行级别列表中按指定的顺序启动
update-rc.d <service> stop <order> <runlevels> 配置服务在运行级别列表中指定的顺序停止
例如,下面的命令序列与命令chkconfig --level 345 apache2 on的作用相同:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
root@10.1.1.200:etc# update-rc.d -f apache2 remove Removing any system startup links for /etc/init.d/apache2 ... /etc/rc0.d/K09apache2 /etc/rc1.d/K09apache2 /etc/rc2.d/S91apache2 /etc/rc3.d/S91apache2 /etc/rc4.d/S91apache2 /etc/rc5.d/S91apache2 /etc/rc6.d/K09apache2root@10.1.1.200:etc# update-rc.d apache2 start 20 3 4 5 . stop 20 0 1 2 6 . Adding system startup for /etc/init.d/apache2 ... /etc/rc0.d/K20apache2 -> ../init.d/apache2 /etc/rc1.d/K20apache2 -> ../init.d/apache2 /etc/rc2.d/K20apache2 -> ../init.d/apache2 /etc/rc6.d/K20apache2 -> ../init.d/apache2 /etc/rc3.d/S20apache2 -> ../init.d/apache2 /etc/rc4.d/S20apache2 -> ../init.d/apache2 /etc/rc5.d/S20apache2 -> ../init.d/apache2 |
|
1
2
3
4
5
6
7
8
9
10
11
12
|
root@10.1.1.200:etc# ls -l /etc/rc3.d/total 4lrwxrwxrwx 1 root root 16 2012-08-13 21:29 K20vsftpd -> ../init.d/vsftpd-rw-r--r-- 1 root root 556 2008-08-12 22:09 READMElrwxrwxrwx 1 root root 17 2012-08-06 00:11 S10rsyslog -> ../init.d/rsysloglrwxrwxrwx 1 root root 15 2012-08-06 00:12 S12acpid -> ../init.d/acpidlrwxrwxrwx 1 root root 14 2012-08-06 00:30 S12dbus -> ../init.d/dbuslrwxrwxrwx 1 root root 13 2012-08-06 00:24 S16ssh -> ../init.d/sshlrwxrwxrwx 1 root root 23 2012-08-06 00:26 S17mysql-ndb-mgm -> ../init.d/mysql-ndb-mgmlrwxrwxrwx 1 root root 19 2012-08-06 00:26 S18mysql-ndb -> ../init.d/mysql-ndblrwxrwxrwx 1 root root 15 2012-08-06 00:26 S19mysql -> ../init.d/mysqllrwxrwxrwx 1 root root 17 2013-01-08 00:21 S20apache2 -> ../init.d/apache2 |
start 20 3 4 5 . : 表示在3,4,5这三个运行级别中,按先后顺序,由小到大,第20个开始运行这个脚本。
stop 20 0 1 2 6 . :表示在0,1,2,6这四个运行级别中,按照先后顺序,由小到大,第20个停止这个脚本的运行。
有个问题就是想要知道某服务处于什么开机启动级别,man update-rc.d也没发现有该选项。只能从/etc/rcX.d去查看。
其实熟悉RH 的chkconfig,在debian中也提供类似的工具,sysv-rc-conf同样是查看所有服务的启动状态.
下面安装sysv-rc-conf
|
1
|
root@10.1.1.200:etc# apt-get install sysv-rc-conf |
|
1
2
3
4
5
6
7
8
9
|
root@10.1.1.200:etc# sysv-rc-conf --listacpid 1:off 2:on 3:on 4:on 5:onapache2 0:off 1:off 2:off 3:on 4:on 5:on 6:offatd 0:off 1:off 2:on 3:on 4:on 5:on 6:offbootlogd S:oncron 1:off 2:on 3:on 4:on 5:ondbus 1:off 2:on 3:on 4:on 5:onexim4 0:off 1:off 2:on 3:on 4:on 5:on 6:offfam 0:off 1:off 2:on 3:on 4:on 5:on 6:off |
|
1
2
3
|
root@10.1.1.200:etc# sysv-rc-conf --level 234 apache2 off root@10.1.1.200:etc# sysv-rc-conf --list apache2apache2 0:off 1:off 2:off 3:off 4:off 5:on 6:off |

浙公网安备 33010602011771号