添加服务到chkconfig中

man chkconfig
For example, random.init has these three lines:
# chkconfig: 2345 20 80 解释:2345 是在这几个级别上默认on 20 80 是启动关闭顺序
# description: Saves and restores system entropy pool for \
# higher quality random number generation.

重点:需要把脚本放在/etc/init.d/目录下

添加:

[root@csa ~]# vim nopsmile.sh 
#!/bin/sh
# chkconfig: 2345 20 80
# description: test
echo "I'm nopsmile"

[root@csa ~]# mv nopsmile.sh /etc/init.d/
[root@csa ~]# chkconfig --add nopsmile.sh 
[root@csa ~]# chkconfig --list | grep nopsmile
nopsmile.sh     0:off   1:off   2:on    3:on    4:on    5:on    6:off
[root@csa ~]# ls -l /etc/rc.d/rc3.d/*nopsmile*
lrwxrwxrwx 1 root root 21 Mar 16 09:09 /etc/rc.d/rc3.d/S20nopsmile.sh -> ../init.d/nopsmile.sh

[root@csa ~]# chkconfig --level 3 nopsmile.sh off
[root@csa ~]# chkconfig --list | grep nopsmile           
nopsmile.sh     0:off   1:off   2:on    3:off   4:on    5:on    6:off
[root@csa ~]# ls -l /etc/rc.d/rc3.d/*nopsmile*
lrwxrwxrwx 1 root root 21 Mar 16 09:16 /etc/rc.d/rc3.d/K80nopsmile.sh -> ../init.d/nopsmile.sh
[on是在S20 ,off是在K80]
删除:

[root@csa ~]# chkconfig --del nopsmile.sh 
[root@csa ~]# chkconfig --list | grep nopsmile
结果是空。
[root@csa ~]# ls -l /etc/rc.d/rc3.d/*nopsmile*
ls: cannot access /etc/rc.d/rc3.d/*nopsmile*: No such file or directory
原理:
/etc/rc.d/ 下2345 如rc3.d/添加链接

转载于:https://blog.51cto.com/4534309/2087431

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值