700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > Linux Shell脚本专栏_批量检测网站是否异常脚本_08

Linux Shell脚本专栏_批量检测网站是否异常脚本_08

时间:2018-12-01 07:09:07

相关推荐

Linux Shell脚本专栏_批量检测网站是否异常脚本_08

文章目录

1. 脚本制作2. 运行脚本3. 脚本进化动态参数传递4. 运行脚本5. 脚本分解

1. 脚本制作

#!/bin/bash URL_LIST=$@for URL in $URL_LIST; doFAIL_COUNT=0for ((i=1;i<=3;i++)); doHTTP_CODE=$(curl -o /dev/null --connect-timeout 3 -s -w "%{http_code}" $URL)if [ $HTTP_CODE -eq 200 ]; thenecho "$URL OK"breakelseecho "$URL retry $FAIL_COUNT"let FAIL_COUNT++fidoneif [ $FAIL_COUNT -eq 3 ]; thenecho "Warning: $URL Access failure!"fidone

2. 运行脚本

[root@localhost app]# ./8.sh retry retry retry 2Warning: Access failure![root@localhost app]#

3. 脚本进化动态参数传递

#!/bin/bash URL_LIST=$@for URL in $URL_LIST; doFAIL_COUNT=0for ((i=1;i<=3;i++)); doHTTP_CODE=$(curl -o /dev/null --connect-timeout 3 -s -w "%{http_code}" $URL)if [ $HTTP_CODE -eq 200 ]; thenecho "$URL OK"breakelseecho "$URL retry $FAIL_COUNT"let FAIL_COUNT++fidoneif [ $FAIL_COUNT -eq 3 ]; thenecho "Warning: $URL Access failure!"fidone

4. 运行脚本

[root@localhost app]# ./8.sh retry retry retry 2Warning: Access failure!

5. 脚本分解

[root@localhost app]# curl -I HTTP/1.1 200 OKAccept-Ranges: bytesCache-Control: private, no-cache, no-store, proxy-revalidate, no-transformConnection: keep-aliveContent-Length: 277Content-Type: text/htmlDate: Mon, 24 Feb 13:54:03 GMTEtag: "575e1f5c-115"Last-Modified: Mon, 13 Jun 02:50:04 GMTPragma: no-cacheServer: bfe/1.0.8.18[root@localhost app]#

[root@localhost app]# curl -o /de/dev/null -s -w "%{http_code}" http://www200[root@localhost app]#

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。