Linux - Apache shell script para determinar se o início

  Determinar se iniciar o Apache, iniciar log; não começou, log, e reiniciar

#!/bin/bash

# Desc: 检测Apache是否启动,如果没有启动,记录日志,并启动
# Author: NangongYi
# Time: 2019/11/05 18:33

# 获取Apache的状态,赋予is_open变量
is_open=$(nmap -sT 192.168.18.128 | grep tcp | grep http | awk '{print $2}')

# 判断,如果Apache开启,记录日志;如果未开,重启,记录日志
if [ "$is_open" == "open" ]
        then
                echo "$(date) httpd is ok!" >> /tmp/httpd.acc.log
        else
                /etc/rc.d/init.d/httpd restart &>/dev/null
                echo "$(date) httpd is restart!" >> /tmp/httpd.err.log
fi

# The End

 

Publicado 59 artigos originais · ganhou elogios 2 · Vistas 5574

Acho que você gosta

Origin blog.csdn.net/LDR1109/article/details/102956818
Recomendado
Clasificación