标签:blog ar 使用 for sp 文件 div on 问题
chkconfig 命令主要用来更新(启动或停止)和查询系统服务的运行级信息。谨记chkconfig不是立即自动禁止或激活一个服务,它只是简单的改变了符号连接。
user@ae01:~$ sudo apt-get install chkconfig
user@ae01:~$ chkconfig --help
usage:
chkconfig -A|--allservices (together with -l: show all services)
chkconfig -t|--terse [names] (shows the links)
chkconfig -e|--edit [names] (configure services)
chkconfig -s|--set [name state]... (configure services)
chkconfig -l|--list [--deps] [names] (shows the links)
chkconfig -c|--check name [state] (check state)
chkconfig -a|--add [names] (runs insserv)
chkconfig -d|--del [names] (runs insserv -r)
chkconfig -h|--help (print usage)
chkconfig -f|--force ... (call insserv with -f)
chkconfig [name] same as chkconfig -t
chkconfig name state... same as chkconfig -s name state
user@ae01:~$
chkconfig 常用的参数有 -l、-a、-s、 -d 如果没有输入参数,chkconfig 默认使用参数 -A,显示前所有的服务并标明开启或关闭状态。如果加上服务名,相当于使用 -t 参数,那么就检查这个服务是否在当前运行级启动。如果是,返回true,否则返回false。如果在服务名后面指定了on,off或者reset,那么chkconfi 会改变指定服务的启动信息。on和off分别指服务被启动和停止,reset指重置服务的启动信息,无论有问题的初始化脚本指定了什么。on和off开关,系统默认只对运行级3,4,5有效,但是reset可以对所有运行级有效。
chkconfig -l | [--list] [names]
chkconfig -a | [--add] [names]
在添加自启动服务之前,必须保证 /etc/init.d/ 目录下有相应的服务脚本。chkconfig确保每个运行级有一项启动(S)或者杀死(K)入口。如有缺少,则会从缺省的init脚本自动建立。
chkconfig -s | [--edit] [names state]
state 可以是 on、off 以及 Linux 的操作环境等级(0123456),在操作过程中可能会因为依赖的关系导致执行失败,可以使用 -f 强制执行。
chkconfig -d|--del [names]
删除服务之后,相应的 /etc/rc[0-6].d/ 文件夹下的服务器的文件也会相应的删除
user@ae01:~$ chkconfig -l mysql
mysql 0:off 1:off 2:off 3:off 4:off 5:off 6:off
user@ae01:~$ chkconfig -a mysql
Ubuntu 12.04 下执行该命令会返回错误 /sbin/insserv: No such file or directory 我们可以看出这是这可能是缺少文件 /sbin/insserv 造成的。对此可以先查找下 insserv 的文件位置
user@ae01:~$ whereis insserv
insserv: /bin/insserv /etc/insserv.conf /etc/insserv /usr/lib/insserv /usr/share/insserv /usr/share/man/man8/insserv.8.gz
user@ae01:~$
可以发现 ll 命令我们逐个查找,发现 insserv 文件的真正存在于 /usr/lib/insserv 目录下
user@ae01:~$ ll /bin/insserv
lrwxrwxrwx 1 root root 24 Oct 28 13:49 /bin/insserv -> /usr/lib/insserv/insserv*
user@ae01:~$
对此,我们可以在 /sbin 目录下创建一个 /usr/lib/insserv/insserv 的软连接
user@ae01:~$ ln -s /usr/lib/insserv/insserv /sbin/insserv
之后我们就可以使用 chkconfig -a 命令。
mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
user@ae01:~$ chkconfig -e mysql
mysql off
or
user@ae01:~$ chkconfig -s mysql on
user@ae01:~$ chkconfig -d mysql
user@ae01:~$ chkconfig -sf mysql 2345
user@ae01:~$ ln -s /etc/init.d/mysql /etc/rc.d/rc2.d/S100mysql
user@ae01:~$ ln -s /etc/init.d/mysql /etc/rc.d/rc3.d/S100mysql
user@ae01:~$ ln -s /etc/init.d/mysql /etc/rc.d/rc4.d/S100mysql
user@ae01:~$ ln -s /etc/init.d/mysql /etc/rc.d/rc5.d/S100mysql
标签:blog ar 使用 for sp 文件 div on 问题
原文地址:http://www.cnblogs.com/tannerBG/p/4063291.html