今天想把自己启动服务的脚本放到/etc/init.d目录下,然后用chkconfig添加的自动启动项中去。结果报错了。
[root@huang ~]# chkconfig --level 2345 lepus on
service lepus does not support chkconfig
查了资料,也看了下mysql的启动脚本发现需要在脚本里加入下面的内存,才可以用chkconfig加入的自动启动项中去。
# chkconfig: 2345 65 35
# description: A os and database monitoring system.
注意:上面的注释的意思是,服务必须在运行级2,3,4,5下被启动或关闭,启动的优先级是65,关闭的优先级是35
添加上面选项后,再添加到启动项就OK了
[root@huang ~]# chkconfig --level 2345 lepus on
[root@huang ~]#
[root@huang ~]# chkconfig --list|grep lepus
lepus 0:off 1:off 2:on 3:on 4:on 5:on 6:off
下面是mysql启动脚本的部分内容
#!/bin/sh
# Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
# This file is public domain and comes with NO WARRANTY of any kind
# MySQL daemon start/stop script.
# Usually this is put in /etc/init.d (at least on machines SYSV R4 based
# systems) and linked to /etc/rc3.d/S99mysql and /etc/rc0.d/K01mysql.
# When this is done the mysql server will be started when the machine is
# started and shut down when the systems goes down.
# Comments to support chkconfig on RedHat Linux
# chkconfig: 2345 64 36
# description: A very fast and reliable SQL database engine.
MYSQL启动脚本的解析我之前写过一个文章
http://blog.youkuaiyun.com/gua___gua/article/details/46138101