1. chkconfig脚本格式
#!/bin/sh
#chkconfig 2345 99 99 // 这是固定格式,2345表示运行级别,之后为开机执行顺序和关机执行顺序。
#description:this is just a demo of chkconfig script // 这也是必须的。
case “$1” in
start)
#description:this is just a demo of chkconfig script // 这也是必须的。
case “$1” in
start)
<start-section>
;;
Stop)
<stop-section>
;;
Status)
Echo <the information you want to display>
;;
*)
Echo “the usage of the script”
Case
2. 保存脚本
将脚本保存,并赋予执行权限,再复制到/etc/init.d目录
#chmod a+x script-file
#cpscript-file /etc/init.d
#chmod a+x script-file
#cpscript-file /etc/init.d
3. 使用chkconfig命令添加成服务
#chkconfig --add script-file
#chkconfig --level 35 script-file on
#chkconfig --list script-file
#chkconfig --add script-file
#chkconfig --level 35 script-file on
#chkconfig --list script-file
4.
通过service命令管理
#service script-file start | stop | status
#service script-file start | stop | status
本文详细介绍了chkconfig脚本的格式、保存、配置、使用等关键步骤,包括运行级别、开机执行顺序、关机执行顺序的设置,以及如何通过chkconfig命令添加成服务,最终通过service命令进行管理。
1676

被折叠的 条评论
为什么被折叠?



