Redhat 装软件一般会带有服务启动的脚本,如果遇到一些软件或者程序需要源码安装则需要,自己编写软件服务的启动程序
1,自定义编写apache的
[root@IBM rc5.d]# cat /etc/init.d/Apache
#!/bin/bash
#下面注释对本身的shell没什么作用,但是对checkconfig这个程序会读取这个注释,- 是默认值,任何级别都不开,可以设置成2345,
#chkconfig: - 80 90
file=/var/run/httpd/httpd.pid
start(){
if [ ! -f $file ];then
/usr/sbin/httpd
echo "httpd 正在运行"
else
echo "已经启动过了"
fi
}
stop(){
if [ -f $file ];then
kill `cat $file`
echo "httpd 正在停止"
else
echo "已经停止了"
fi
}
case $1 in
start)
start;;
stop)
stop;;
restart)
kill `cat $file`
echo "httpd 正在停止"
sleep 1
/usr/sbin/httpd
echo "httpd 正在启动";;
status)
if [ -f $file ];then
echo "Aapche 正在运行"
else
echo "Apache 没有运行"
fi;;
*)
echo "usage: {start|stop|status}";;
esac
#重复的代码可以做成一个函数,直接掉