Apached启动脚本
2016-09-23 17:21
211 查看
#vi /etc/init.d/apached
#!/bin/bash
#chkconfig: - 85 15
#description: Apache is a Web server
APA=/usr/local/httpd2/bin/apachectl
NET=$(netstat -antpu | grep :80)
start(){
if [ -n "$NET" ];then
echo " Apache server is running"
return 88
else
echo -en "\e[0;32m Starting Apache \e[0m......\t\t\t"
$APA start
echo -e "\e[0;32m[OK]\e[0m"
fi
}
stop(){
if [ -z "$NET" ];then
echo "Apache server is stopped"
else
echo -en "\e[0;32m Stopping Apache \e[0m......\t\t\t"
$APA stop
echo -e "\e[0;32m[OK]\e[0m"
fi
}
status(){
if [ -n "$NET" ];then
echo -e "\e[0;32m Apache server is running\e[0m......\t\e[0;32m[OK]\e[0m"
else
echo -e "\e[0;32m Apacheserver is stopped \e[0m......\t\e[0;32m[OK]\e[0m"
fi
}
restart(){
echo -en "\e[0;32m Rstarting Apache \e[0m......\t\t\t"
$APA start &> /dev/null
echo -e "\e[0;32m[OK]\e[0m"
}
case $1 in
"start")
start;;
"stop")
stop;;
"status")
status;;
"restart")
restart;;
*)
echo " start | stop | status | restart "
esac
然后:添加权限和加入自启动
# chmod +x /etc/init.d/apached
# chkconfig --add apached
# chkconfig apached on
# chkconfig --list apached
再然后就可以如下操作了:
# service apached start | stop | status| restart
#!/bin/bash
#chkconfig: - 85 15
#description: Apache is a Web server
APA=/usr/local/httpd2/bin/apachectl
NET=$(netstat -antpu | grep :80)
start(){
if [ -n "$NET" ];then
echo " Apache server is running"
return 88
else
echo -en "\e[0;32m Starting Apache \e[0m......\t\t\t"
$APA start
echo -e "\e[0;32m[OK]\e[0m"
fi
}
stop(){
if [ -z "$NET" ];then
echo "Apache server is stopped"
else
echo -en "\e[0;32m Stopping Apache \e[0m......\t\t\t"
$APA stop
echo -e "\e[0;32m[OK]\e[0m"
fi
}
status(){
if [ -n "$NET" ];then
echo -e "\e[0;32m Apache server is running\e[0m......\t\e[0;32m[OK]\e[0m"
else
echo -e "\e[0;32m Apacheserver is stopped \e[0m......\t\e[0;32m[OK]\e[0m"
fi
}
restart(){
echo -en "\e[0;32m Rstarting Apache \e[0m......\t\t\t"
$APA start &> /dev/null
echo -e "\e[0;32m[OK]\e[0m"
}
case $1 in
"start")
start;;
"stop")
stop;;
"status")
status;;
"restart")
restart;;
*)
echo " start | stop | status | restart "
esac
然后:添加权限和加入自启动
# chmod +x /etc/init.d/apached
# chkconfig --add apached
# chkconfig apached on
# chkconfig --list apached
再然后就可以如下操作了:
# service apached start | stop | status| restart
相关文章推荐
- 安装apached源码包以及编写shell脚本使其启动更加方便,并且和启动系统服务相同
- 自动监控进程并启动的shell脚本
- Windows下Nginx启动脚本
- 启动脚本中避免目标地址为域名的网络连接
- Hadoop 2.2.0启动脚本——bin/hdfs
- php-fpm开机自动启动Shell脚本
- debian6启动脚本详解
- nginx启动脚本和配置文件
- Spark 0.9.0启动脚本——sbin/start-slaves.sh
- init.d目录、rc#.d目录和rc.local脚本——系统服务的启动和停止
- 在window xp下使用eventquery.vbs脚本输出当天电脑每次的启动时间
- linux tomcat 启动脚本 说明
- linux下环境变量、启动脚本、进程判断设置
- oracle10g在redhat4 下面的启动脚本
- HOWTO:InstallShield脚本中如何启动某一程序
- CentOS 7中添加开机启动脚本
- Spark 0.9.0启动脚本——bin/spark-class
- 关于Tomcat脚本启动闪退问题
- Windows Nginx 下启动关闭的管理批处理脚本
- tomcat 启动脚本