开机启动shell脚本,红旗

http://blog.csdn.net/wwwxxlby520/article/details/4374079

http://flandycheng.blog.51cto.com/855176/292900

 

3. 启动 脚本 示例
这是一个用来启动 httpd的 /etc/rc.d/init.d/apache脚本

CODE:

#!/bin/bash

source /etc/sysconfig/rc
source $rc_functions

case "$1" in
start)
echo "Starting Apache daemon..."
/usr/local/apache2/bin/apachectl -k start
evaluate_retval
;;

stop)
echo "Stopping Apache daemon..."
/usr/local/apache2/bin/apachectl -k stop
evaluate_retval
;;

restart)
echo "Restarting Apache daemon..."
/usr/local/apache2/bin/apachectl -k restart
evaluate_retval
;;

status)
statusproc /usr/local/apache2/bin/httpd
;;

*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac


可以看出他接受start,stop,restart,status参数

然后可以这样建立rc?.d的链接:

CODE:

cd /etc/rc.d/init.d &&
ln -sf ../init.d/apache ../rc0.d/K28apache &&
ln -sf ../init.d/apache ../rc1.d/K28apache &&
ln -sf ../init.d/apache ../rc2.d/K28apache &&
ln -sf ../init.d/apache ../rc3.d/S32apache &&
ln -sf ../init.d/apache ../rc4.d/S32apache &&
ln -sf ../init.d/apache ../rc5.d/S32apache &&
ln -sf ../init.d/apache ../rc6.d/K28apache


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值