原 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 |
虽然debian的update-rc.d与RH的chkconfig工具相类似。不同的是chkconfig是一个二进制程序,而update-rc.d是一个Perl脚本。这些工具有不同的命令行选项,但是却执行类似的功能。下表列出了update-rc.d的一些用法。
命令 功能
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 |
第一个命令移除了所有的指向/etc/init.d/apache2服务脚本的运行级别链接,-f标志将会使得update-rc.d即使在apache2脚本本身已经存在的情况仍然进行相应的处理。第二个命令在每一个运行级别创建了一个服务级别为20的启动/停止脚本。这些脚本的连接位于/etc/rcX.d/LnName,对应脚本位于/etc/init.d/Script-name。对于已经存的启动脚本链接, 如再次执行第二个命令会发现 System startup links for /etc/init.d/apache2 already exist,必须将其remove掉,再进行相关的操作。
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 |
原 Debian设置开机自动启动与关闭的更多相关文章
- Mongodb 启动关闭脚本并设置开机自动启动Mongodb
配置文件内容:[root@yoon etc]# cat mongod.conf logpath=/export/log/mongodb.loglogappend=truefork = truedbpa ...
- CentOS 7.6 RPM 方式安装Oracle19c 后 使用 systemd 的方式设置开机自动启动Oracle数据库
1. 方法简介: 使用systemd 来进行 oracle数据库的启动和关闭操作. 使用的脚本为 lsnrctl和dbstart 2. 修改事项. 需要先修改一下 oracle 的启动脚本配置: vi ...
- CentOS设置开机自动启动某服务
CentOS设置开机自动启动某服务 这里以启动sshd服务为例: 查看sshd是否已经是系统服务: # chkconfig --list |grep sshd 会显示: sshd ...
- centos下安装memcached并设置开机自动启动-两种方法
方法一: 安装memcachedyum install memcached 启动服务并初始化service memcached start -p 11211 -l 127.0.0.1 -d 设置mem ...
- VMware ESXi 6.7服务器设置开机自动启动虚拟机
VMware ESXi 6.7服务器设置开机自动启动虚拟机,具体操作步骤如下 1.登陆到VMware ESXi 6.7 web 界面 2.导航器-->主机-->管理 将自动启动修改为 ...
- [转] ubuntu16.04添加系统 service, 并设置开机自动启动
转:https://www.jianshu.com/p/1958878646bd 1. 创建pfly.service文件 2. 执行 systemctl daemon-reload 3. 执行 sy ...
- 在Linux环境安装redis步骤,且设置开机自动启动redis
最近在linux环境安装了redis学习,目前已经安装成功且设置开机即启动状态,我把步骤流程记录了下来,分享给需要的小伙伴. 1.我在/usr/local/localsoftware/目录下创建了一个 ...
- win10如何设置开机自动启动热点WIFI?
1.编写脚本文件(先新建txt文件,编写代码内容netsh wlan start hostednetwork,最后重命名成HotSpot.bat):文件名称:HotSpot.bat,代码内容: net ...
- Centos7下源编译安装Postgresql 并设置开机自动启动postgresql.serivce 服务相关研究
编写开机自动启动服务脚本: # cat >> /usr/lib/systemd/system/postgresql.service >> EOF [Unit] Descript ...
随机推荐
- Android 主题动态切换框架:Prism
Prism(棱镜) 是一个全新的 Android 动态主题切换框架,虽然是头一次发布,但它所具备的基础功能已经足够强大了!本文介绍了 Prism 的各种用法,希望对你会有所帮助,你也可以对它进行扩展, ...
- 使用 EasyBCD 安装Ubuntu 14.04 Error 15: file not found错误的解决方法
今天安装Window7 和 Ubuntu 14.04 双系统时,出现如下异常,记录一下. 安装过程是参考 http://www.linuxidc.com/Linux/2014-04/100369.ht ...
- Android编译过程详解(一)
Android编译过程详解(一) 注:本文转载自Android编译过程详解(一):http://www.cnblogs.com/mr-raptor/archive/2012/06/07/2540359 ...
- 说说QQ空间SEO
其实这个话题由来已久,已经有很多大神做到QQ空间日访问量破万,甚至更多了,卖产品卖到抽筋儿. 怎么说QQ空间SEO,其实不如说QQ空间引流更合适,因为QQ空间与QQ的特殊关系,SEO貌似不是很重要,其 ...
- Win7旗舰版的nfs服务器如何架设? - Microsoft Community
Win7旗舰版的nfs服务器如何架设? - Microsoft Community Win7旗舰版的nfs服务器如何架设?
- TCP/IP协议栈及OSI参考模型详解
OSI参考模型 OSI RM:开放系统互连参考模型(open systeminterconnection reference model) OSI参考模型具有以下优点: 简化了相关的网络操作: 提供设 ...
- Java网络编程(模拟浏览器访问Tomcat服务器)
程序运行结果: HTTP/1.1 404 Not FoundServer: Apache-Coyote/1.1Content-Type: text/html;charset=utf-8Content- ...
- SQL2008-查询库中是否存在某表
select * from sysobjects where name= 'N201111B' and xtype= 'U'
- hdoj 1405 The Last Practice
The Last Practice Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- ALM11需求类型