原版的脚本里  查看status  需要用 lynx这个命令,还要开启http://localhost:80/server-status  
比较麻烦,我直接注释了,新加的代码用红色字体
 
 
 
 
#!/bin/sh
#chkconfig: 2345 50 90
#description: httpd is web server
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# Apache control script designed to allow an easy command line interface
# to controlling Apache.  Written by Marc Slemko, 1997/08/23
# The exit codes returned are:
#   XXX this doc is no longer correct now that the interesting
#   XXX functions are handled by httpd
#0 - operation completed successfully
#1 - 
#2 - usage error
#3 - httpd could not be started
#4 - httpd could not be stopped
#5 - httpd could not be started during a restart
#6 - httpd could not be restarted during a restart
#7 - httpd could not be restarted during a graceful restart
#8 - configuration syntax error
#
# When multiple arguments are given, only the error from the _last_
# one is reported.  Run "apachectl help" for usage info
#
ARGV="$@"
#
# |||||||||||||||||||| START CONFIGURATION SECTION  ||||||||||||||||||||
# --------------------                              --------------------
# the path to your httpd binary, including options if necessary
HTTPD='/usr/local/apache/bin/httpd'
#
# pick up any necessary environment variables
if test -f /usr/local/apache/bin/envvars; then
  . /usr/local/apache/bin/envvars
fi
#
# a command that outputs a formatted text version of the HTML at the
# url given on the command line.  Designed for lynx, however other
# programs may work.  
LYNX="lynx -dump"
#
# the URL to your server's mod_status status page.  If you do not
# have one, then status and fullstatus will not work.
STATUSURL="http://localhost:80/server-status"
#
# Set this variable to a command that increases the maximum
# number of file descriptors allowed per child process. This is
# critical for configurations that use many file descriptors,
# such as mass vhosting, or a multithreaded server.
ULIMIT_MAX_FILES="ulimit -S -n `ulimit -H -n`"
 
status1=$(ps -ef | egrep "/usr/local/apache/bin/httpd -k start" | grep -v 'grep')
 
  #status 
function httpd_status() { 
    if [ "${status1}X" != "X" ];then 
        echo "httpd service is running !"   
    else
         echo "httpd service is not running !"  
    fi 
 
# --------------------                              --------------------
# ||||||||||||||||||||   END CONFIGURATION SECTION  ||||||||||||||||||||
 
# Set the maximum number of file descriptors allowed per child process.
if [ "x$ULIMIT_MAX_FILES" != "x" ] ; then
    $ULIMIT_MAX_FILES
fi
 
ERROR=0
if [ "x$ARGV" = "x" ] ; then 
    ARGV="-h"
fi
 
case $ARGV in
start|stop|restart|graceful|graceful-stop)
    $HTTPD -k $ARGV
    ERROR=$?
    ;;
startssl|sslstart|start-SSL)
    echo The startssl option is no longer supported.
    echo Please edit httpd.conf to include the SSL configuration settings
    echo and then use "apachectl start".
    ERROR=2
    ;;
configtest)
    $HTTPD -t
    ERROR=$?
    ;;
status)
   #$LYNX $STATUSURL | awk ' /process$/ { print; exit } { print } '
   httpd_status
    ;;
fullstatus)
    $LYNX $STATUSURL
    ;;
*)
    $HTTPD $ARGV
    ERROR=$?
esac
 
exit $ERROR
 

shell脚本 server httpd 控制程序的更多相关文章

  1. shell脚本监控httpd服务80端口状态

    监控httpd服务端口状态,根据端口判断服务器是否启动,如果没有启动则脚本自动拉起服务,如果服务正在运行则退出脚本程序:如果换成别的服务端口也可以,但是脚本程序需要做调整. #!/bin/bash # ...

  2. 案例六:shell脚本监控httpd服务80端口状态

    这里是举例监控httpd服务端口状态,根据端口判断服务器是否启动,如果没有启动则脚本自动拉起服务,如果服务正在运行则退出脚本程序:如果换成别的服务端口也可以,但是脚本程序需要做调整. #!/bin/b ...

  3. Shell脚本 server rsync 控制脚本

    [root@backup ~]# vim /etc/init.d/rsync#!/bin/bash #this script for start|stop rsync daemon service s ...

  4. SQL Server 中执行Shell脚本计算本地文件的内容大小

    SQL Server 数据库中除了能执行基本的SQL语句外,也可以执行Shell脚本.默认安装后,SQL中的Shell脚本的功能是关闭的,需要手动打开, 执行以下脚本即可打开该功能. -- 允许配置高 ...

  5. 将shell脚本运行情况写入Rsyslog日志server

    在运维工作中,免不了编写一些脚本交由计划任务(cron)去定时运行完毕一些日常工作,实现运维工作自己主动化.比方在我的日常工作中备份数据是一项重要的工作,须要定时将数据备份到备份服器和一些其它的备份介 ...

  6. Shell脚本监控Linux某个后台进程,当进程死掉后重新启动服务,以httpd为例

    Shell脚本如下: vim monitor.sh #!/bin/bash while true # 无限循环 flag=`ps -aux |grep "httpd" |grep ...

  7. 使用 shell 脚本实现 LANMP 一键安装

    使用 shell 脚本来实现 LANMP 系统的一键安装.使用的操作系统是 CentOS 6 ,不区分 32 位和 64 位,要求机器可以连通互联网.支持 LAMP 和 LNMP ,MySQL 支持 ...

  8. shell脚本二

    在shell脚本一 中,我讨论了shell脚本的语法规范,shell脚本的变量,以及shell脚本的测试语句. 仅仅懂得这些只能写简单的脚本,在简单的脚本中各条语句按顺序执行,从而实现自动化的管理,顺 ...

  9. 【linux】系统初始化的shell脚本

    根据参考网上的一些文章,总结出来一个系统初始化的shell脚本 1.初始化脚本 #!/bin/bash cat << EOF +------------------------------ ...

随机推荐

  1. 1.PL/SQL Developer的快捷键

    设置步骤: Configure  =>  preference => 用户界面 => 编辑器  => 自动替换 => 启用 => 编辑 =>保存(产生一个文件 ...

  2. Openstack之七:实现基于桥接的内外网络

    一.在控制端进行配置网络 #启动实例文档:https://docs.openstack.org/ocata/zh_CN/install-guide-rdo/launch-instance.html# ...

  3. 区间dp - 送外卖

    When we are focusing on solving problems, we usually prefer to stay in front of computers rather tha ...

  4. net 自带cache

    using System.Web.Caching; Cache cache = new Cache();

  5. java实现FTP文件下载

    package com.vingsoft.util;/*** @author 作者:dujj* @version 创建时间:2020年1月13日 下午5:53:39*/import java.io.F ...

  6. 深入理解Java虚拟机-类加载连接和初始化解析

    不管学习什么,我一直追求的是知其然,还要知其所以然,对真理的追求可以体现在方方面面.人生短短数十载,匆匆一世似烟云,我认为,既然来了,就应该留下一些有意义的东西.本系列文章是结合张龙老师的<深入 ...

  7. Java中SMB的相关应用

    目录 SMB 服务操作 Ⅰ SMB简介 Ⅱ SMB配置 2.1 Windows SMB Ⅲ 添加SMB依赖 Ⅳ 路径格式 Ⅴ 操作共享 Ⅵ 登录验证 SMB 服务操作 Ⅰ SMB简介 ​ SMB(全称 ...

  8. widows 10 下解决在npm install python 环境报错的问题

    1.使用管理员打开cmd 2.安装 node-gyp; gyp是一种根据c++源代码编译的工具,node-gyp就是为node编译c++扩展的时候使用的编译工具. npm install -g nod ...

  9. 【WPF学习】第二十七章 Application类的任务

    上一章介绍了有关WPF应用程序中使用Application对象的方式,接下来看一下如何使用Application对象来处理一些更普通的情况,接下俩介绍如何初始化界面.如何处理命名行参数.如何处理支付窗 ...

  10. B语言的发明者 Ken Thomson & C语言的发明者Dennis Ritchie

    C语言的发明者Ken Thomson因为没有参加C语言考试,在Google没有提交代码的权力. 哀悼结束,生活还要继续. 说段趣闻吧.大家都知道,C语言和Unix的发明者.图灵奖得主.最具传奇性的程序 ...