原 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 ...
随机推荐
- Centos 下Nginx 自启动脚本
#!/bin/bash #ckconfig: NGINX_PATH=/web/container/nginx- NGINX_COMMAND=$NGINX_PATH/sbin/nginx NGINX_P ...
- 关于设置sqlplus提示符样式的方法
摘要:大家在日常工作中,我想99%都会用到sqlplus工具来登陆你的数据库,对数据库进行管理.调优.配置.运维.那么如果有n多台数据库的时候,我们在连接后全部是统一的SQL>提示符,就有可能发 ...
- 用JS动态创建登录表单,报了个小错误
后来发现原来是: dvObj.style.border='#Red 1px sold'; 其中的Red多谢了一个‘#’, 但是奇怪的是在chrome和firefox都备有报错,但是在ie中报错了. 各 ...
- [Bhatia.Matrix Analysis.Solutions to Exercises and Problems]ExI.5.2
The elementary tensors $x\otimes \cdots \otimes x$, with all factors equal, are all in the subspace ...
- 基于kryonet的RPC,使用kryo进行序列化
Kryo是一个序列化框架. Kryonet是一个基于kryo的RPC框架,它实现了一套高效简洁的API,它通过NIO实现了TCP和UDP通讯,目前还不支持Http. 自己写了一个测试代码,运行了下,感 ...
- Balanced Numbers(数位+状压)
题意:求给定区间,一个数的数位上每个奇数出现偶数次,每个偶数出现奇数次,这样数的个数 分析:先考虑状态,但总是想不全,所以要把状态压缩一下,用三进制,0 该数不放 1 放了奇数次 2放了偶数次 dp ...
- fedora下的dropbox
- SELinux的故障排除一例
刚刚采用Puppet部署了dokuwiki,不过配置完成后报错: DokuWiki Setup Error The datadir ('pages') at /pages is not found, ...
- Base-Android快速开发框架(一)--概述
首先简单介绍一下Base.Base是本人长期以来经过10来款APP总结出来的一个Android快速开发框架.包含数据缓存模块.工具包.第三方组件包.网络模块.数据解析.常用主界面布局等.可以快速的开发 ...
- linux 学习之 rpm
目前最常见的两种软件安装方式: 1.dpkg 2.rpm 1.dpkg 最早是由Debian Linux社群开发出来的,通过dpkg,Debian提供的软件就可以简单的安装,同时还能提供安装后的软件信 ...