SHELL-将脚本加入到service服务中
# vi test#!/bin/bash
#chkconfig: 345 38 83
#description: test
restart(){
/etc/init.d/iptables restart
}
case "$1" in
rest)
restart
;;
*)
echo $"Usage:$0 {rest}"
esac
~
~
~
~
~
~
~
~
~
~
"test" 13L, 202C written
#chmod +x test.sh
#cp -a test.sh /etc/init.d/test
#chkconfig --add test
# service test rest
iptables: Flushing firewall rules:
iptables: Setting chains to policy ACCEPT: filter
iptables: Unloading modules:
iptables: Applying firewall rules:
注释:
1、写好shell;
2、赋予执行权限;
3、复制到/etc/init.d下;
4、添加到服务chkconfig --add test;
5、测试。
chkconfig: 345 38 83 启动在3 4 5三个级别,启动和关闭的需要,在/etc/rc(3~5).d中可以找到:
# pwd
/etc/rc4.d
# ls | grep 38
S38test
# ll | grep test
lrwxrwxrwx. 1 root root 14 Sep 10 11:51 S38test -> ../init.d/test
页:
[1]