Chkconfig 添加系统服务

本文详细介绍了chkconfig脚本的格式、保存、配置、使用等关键步骤,包括运行级别、开机执行顺序、关机执行顺序的设置,以及如何通过chkconfig命令添加成服务,最终通过service命令进行管理。
1. chkconfig脚本格式
#!/bin/sh
#chkconfig 2345 99 99 // 这是固定格式,2345表示运行级别,之后为开机执行顺序和关机执行顺序。
#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

3. 使用chkconfig命令添加成服务
#chkconfig --add script-file
#chkconfig --level 35 script-file on
#chkconfig --list script-file

4. 通过service命令管理
#service script-file start | stop | status
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值