简单的shell脚本tomcat启动与关闭
- 格式:docx
- 大小:18.32 KB
- 文档页数:1
#!/bin/bash
url=url.txt
for i in $(cat $url);do
# wget -o file.txt $i
curl -L -I $i > file.txt
test=`awk 'NR==14 {print $2}' file.txt`
if [ $test -eq 200 ];then
echo "$i is ture,$(date)" >> url_ture
echo "tomcat正常,不用重启"
else
echo "$i is fales,$(date)" >> url_false
echo "tomcat异常,需要重启"
echo "$(date)"
echo "开始重启tomcat,第一步将tomcat的进程关闭"
tomcatID=$(ps -ef |grep tomcat |grep /usr/java/tomcat |grep -v 'grep'|`awk '{print $2}'`)
STARTTOMCAT=/usr/java/tomcat/bin/startup.sh
kill -9 $tomcatID
sleep 3
$STARTTOMCAT
fi
done
exit