wget\u547d\u4ee4<\/strong><\/span><\/div>\nwget\u547d\u4ee4\u7684\u53c2\u6570\u975e\u5e38\u591a\uff0c\u81f3\u5c11\u4e5f\u6709\u6570\u5341\u4e2a\uff0c \u4f46\u662f\u8fd0\u7ef4\u5de5\u4f5c\u4e2d\u5e38\u7528\u7684\u5e76\u4e0d\u591a\uff0c\u8001\u7537\u5b69\u8001\u5e08\u628a\u6700\u6709\u7528\u7684\u5217\u8868\u5982\u4e0b\u3002<\/p>\n
\r\n wget\u547d\u4ee4 \t \u4e0b\u8f7d\u7f51\u9875\u6216\u6587\u4ef6\r\n --spider \t \u6a21\u62df\u722c\u866b\u7684\u884c\u4e3a\u53bb\u8bbf\u95ee\u7f51\u7ad9\uff0c\u4f46\u4e0d\u4f1a\u4e0b\u8f7d\u7f51\u9875\r\n -q, --quiet \t \u5b89\u9759\u7684\u8bbf\u95ee\uff0c\u7981\u6b62\u8f93\u51fa\uff0c\u7c7b\u4f3c-o \/dev\/null\u529f\u80fd\r\n -o, --output-file=FILE \t \u8bb0\u5f55\u8f93\u51fa\u5230\u6587\u4ef6\r\n -T, --timeout=SECONDS \t \u8bbf\u95ee\u7f51\u7ad9\u7684\u8d85\u65f6\u65f6\u95f4\r\n -t, --tries=NUMBER \t \u5f53\u7f51\u7ad9\u5f02\u5e38\u65f6\u91cd\u8bd5\u7f51\u7ad9\u7684\u6b21\u6570\r\n<\/pre>\n\u5b9e\u9645\u76d1\u63a7\u65b9\u6cd5\u5982\u4e0b\uff1a\u5229\u7528wget\u547d\u4ee4\u8fd4\u56de\u503c\u786e\u5b9a\u7f51\u7ad9\u662f\u5426\u6b63\u5e38<\/p>\n
\r\n\u3000\u3000[root@oldboy ~]# wget --spider -T 5 -q -t 2 www.oldboyedu.com\r\n\r\n\u3000\u3000[root@oldboy ~]# echo $? #< ==\u5229\u7528\u8fd4\u56de\u503c\u786e\u5b9a\u7f51\u7ad9\u662f\u5426\u6b63\u5e38\u3002\r\n\r\n\u3000\u30000\r\n<\/pre>\ncurl\u547d\u4ee4<\/strong><\/span><\/div>\ncurl\u547d\u4ee4\u7684\u53c2\u6570\u6bd4wget\u7684\u53c2\u6570\u8fd8\u591a\uff0c\u4f46\u8fd0\u7ef4\u4e2d\u5e38\u7528\u7684\u53c2\u6570\u4e5f\u5e76\u4e0d\u591a\uff0c\u56e0\u6b64\u4e5f\u662f\u5217\u8868\u5982\u4e0b\uff1a<\/p>\n
\r\n curl\u547d\u4ee4 \t \u8bbf\u95ee\u7f51\u7ad9url\r\n -I\/--head \t \u663e\u793a\u54cd\u5e94\u5934\u4fe1\u606f\r\n -m\/--max-time \t \u8bbf\u95ee\u8d85\u65f6\u7684\u65f6\u95f4\r\n -o\/--output \t \u8bb0\u5f55\u8bbf\u95ee\u4fe1\u606f\u5230\u6587\u4ef6\r\n -s\/--silent \t \u6c89\u9ed8\u6a21\u5f0f\u8bbf\u95ee\uff0c\u5c31\u662f\u4e0d\u8f93\u51fa\u4fe1\u606f\r\n -w\/--write-out \t \u4ee5\u56fa\u5b9a\u7279\u6b8a\u7684\u683c\u5f0f\u8f93\u51fa\uff0c\u4f8b\u5982\uff1a%{http_code}\uff0c\u8f93\u51fa\u72b6\u6001\u7801\r\n<\/pre>\n\u5b9e\u9645\u76d1\u63a7\u65b9\u6cd5<\/strong><\/span><\/div>\n1\u3001\u5229\u7528curl\u547d\u4ee4\u8fd4\u56de\u503c\u786e\u5b9a\u7f51\u7ad9\u662f\u5426\u6b63\u5e38<\/p>\n
\r\n\u3000\u3000[root@oldboy ~]# curl -s -o \/dev\/null www.oldboyedu.com\r\n\r\n\u3000\u3000[root@oldboy ~]# echo $?\r\n\r\n\u3000\u30000\r\n<\/pre>\n2\u3001\u83b7\u53d6\u547d\u4ee4\u6267\u884c\u540e\u7684\u72b6\u6001\u7801(200\u8868\u793a\u6b63\u5e38)<\/p>\n
\r\n\u3000\u3000[root@oldboy ~]# curl -I -m 5 -s -w \"%{http_code}\\n\" -o \/dev\/null www.baidu.com\r\n\r\n\u3000\u3000200\r\n<\/pre>\n3 \u5f00\u53d1Shell\u811a\u672c\u5b9e\u73b0\u76d1\u63a7\u6307\u5b9a\u7684URL\u662f\u5426\u6b63\u5e38<\/p>\n
\r\n\u3000\u3000\u89e3\u7b54\uff1a\r\n\r\n\u3000\u3000\u65b9\u6cd51\uff1a\r\n\r\n\u3000\u3000#!\/bin\/sh\r\n\r\n\u3000\u3000function usage() { #< ==\u5e2e\u52a9\u51fd\u6570\r\n\r\n\u3000\u3000echo $\"usage:$0 url\"\r\n\r\n\u3000\u3000exit 1\r\n\r\n\u3000\u3000}\r\n\r\n\u3000\u3000function check_url() { #<==\u68c0\u6d4bURL\u51fd\u6570\u3002\r\n\r\n\u3000\u3000wget --spider -q -o \/dev\/null --tries=1 -T 5 $1\r\n\r\n\u3000\u3000#<==\u91c7\u7528wget\u8fd4\u56de\u503c\u65b9\u6cd5\uff0c\u8fd9\u91cc\u7684$1\u5c31\u662f\u51fd\u6570\u4f20\u53c2\u3002\r\n\r\n\u3000\u3000#curl -s -o \/dev\/null $1 #<==\u91c7\u7528curl\u8fd4\u56de\u503c\u65b9\u6cd5\u4e5f\u662f\u53ef\u4ee5\u7684\u3002\r\n\r\n\u3000\u3000if [ $? -eq 0 ]\r\n\r\n\u3000\u3000then\r\n\r\n\u3000\u3000echo \"$1 is yes.\"\r\n\r\n\u3000\u3000exit 0\r\n\r\n\u3000\u3000else\r\n\r\n\u3000\u3000echo \"$1 is fail.\"\r\n\r\n\u3000\u3000exit 1\r\n\r\n\u3000\u3000fi\r\n\r\n\u3000\u3000}\r\n\r\n\u3000\u3000function main() { #<==\u4e3b\u51fd\u6570\u3002\r\n\r\n\u3000\u3000if [ $# -ne 1 ] #<==\u5982\u679c\u4f20\u5165\u7684\u591a\u4e2a\u53c2\u6570\uff0c\u5219\u6253\u5370\u5e2e\u52a9\u51fd\u6570\uff0c\u63d0\u793a\u7528\u6237\u3002\r\n\r\n\u3000\u3000then\r\n\r\n\u3000\u3000usage\r\n\r\n\u3000\u3000fi\r\n\r\n\u3000\u3000check_url $1 #<==\u63a5\u6536\u51fd\u6570\u7684\u4f20\u53c2\uff0c\u5373\u628a\u7ed3\u5c3e\u7684$*\u4f20\u5230\u8fd9\u91cc\u3002\r\n\r\n\u3000\u3000}\r\n\r\n\u3000\u3000main $* #<==\u8fd9\u91cc\u7684$*\u5c31\u662f\u628a\u547d\u4ee4\u884c\u63a5\u6536\u7684\u6240\u6709\u53c2\u6570\u4f5c\u4e3a\u51fd\u6570\u53c2\u6570\u4f20\u7ed9\u51fd\u6570\u5185\u90e8\uff0c\u5e38\u7528\u624b\u6cd5\u3002\r\n<\/pre>\n\u5b9e\u8df5\u7ed3\u679c<\/strong><\/span><\/div>\n\r\n\u3000\u3000[root@oldboy ~]# sh checkurl.sh www.oldboyedu.com\r\n\r\n\u3000\u3000www.oldboyedu.com is ok\r\n\r\n\u3000\u3000[root@oldboy ~]# sh checkurl.sh www.baidu.com\r\n\r\n\u3000\u3000www.baidu.com is ok\r\n\r\n\u3000\u3000[root@oldboy ~]# sh checkurl.sh 10.0.0.8\r\n\r\n\u3000\u300010.0.0.8 is fail\r\n\r\n\u3000\u3000\u65b9\u6cd52\uff1a\r\n\r\n\u3000\u3000[root@oldboy ~]# cat checkurl1.sh\r\n\r\n\u3000\u3000#!\/bin\/bash\r\n\r\n\u3000\u3000##############################################################\r\n\r\n\u3000\u3000# File Name: checkurl.sh\r\n\r\n\u3000\u3000# Version: V1.0\r\n\r\n\u3000\u3000# Author: oldboy\r\n\r\n\u3000\u3000# Organization: www.oldboyedu.com\r\n\r\n\u3000\u3000# Created Time : 2018-06-07 18:29:19\r\n\r\n\u3000\u3000##############################################################\r\n\r\n\u3000\u3000usage(){\r\n\r\n\u3000\u3000echo \"Usage:$0 url\"\r\n\r\n\u3000\u3000exit 1\r\n\r\n\u3000\u3000}\r\n\r\n\u3000\u3000checkurl(){\r\n\r\n\u3000\u3000local num=`curl -I -m 5 -s -w \"%{http_code}\\n\" -o \/dev\/null|grep 200|wc -l`\r\n\r\n\u3000\u3000if [ $num -eq 1 ] #< ==\u91c7\u7528\u83b7\u53d6\u72b6\u6001\u7801\uff0c\u5e76\u8f6c\u4e3a\u6570\u5b57\u7684\u65b9\u5f0f\u5224\u65ad\uff0c\u5982\u679c301\u8ba4\u4e3a\u6b63\u786e\u4e5f\u53ef\u4ee5\u52a0\u4e0aegrep\u8fc7\u6ee4\u3002\r\n\r\n\u3000\u3000then\r\n\r\n\u3000\u3000echo \"$1 is ok\"\r\n\r\n\u3000\u3000else\r\n\r\n\u3000\u3000echo \"$1 is fail\"\r\n\r\n\u3000\u3000fi\r\n\r\n\u3000\u3000}\r\n\r\n\u3000\u3000main(){\r\n\r\n\u3000\u3000if [ $# -ne 1 ]\r\n\r\n\u3000\u3000then\r\n\r\n\u3000\u3000usage\r\n\r\n\u3000\u3000fi\r\n\r\n\u3000\u3000checkurl $1\r\n\r\n\u3000\u3000}\r\n\r\n\u3000\u3000main $*\r\n<\/pre>\n\u5b9e\u8df5\u7ed3\u679c<\/strong><\/span><\/div>\n\r\n\u3000\u3000[root@oldboy ~]# sh checkurl.sh www.oldboyedu.com\r\n\r\n\u3000\u3000www.oldboyedu.com is ok\r\n\r\n\u3000\u3000[root@oldboy ~]# sh checkurl.sh www.baidu.com\r\n\r\n\u3000\u3000www.baidu.com is ok\r\n\r\n\u3000\u3000[root@oldboy ~]# sh checkurl.sh 10.0.0.8\r\n\r\n\u3000\u300010.0.0.8 is fail\r\n<\/pre>\n\u3000\u3000\u5982\u679c\u7f51\u53cb\u80fd\u5426\u8bfb\u61c2\u672c\u6587\uff0c\u76f8\u4fe1\u4ee5\u540e\u518d\u5199\u76d1\u63a7\u7f51\u7ad9URL\u7684\u811a\u672c\u5c31\u4f1a\u5f88\u8f7b\u677e\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
wget\u547d\u4ee4\u7684\u53c2\u6570\u975e\u5e38\u591a\uff0c\u81f3\u5c11\u4e5f\u6709\u6570\u5341\u4e2a\uff0c \u4f46\u662f\u8fd0\u7ef4\u5de5\u4f5c\u4e2d\u5e38\u7528\u7684\u5e76\u4e0d\u591a\uff0c\u8001\u7537\u5b69\u8001\u5e08\u628a\u6700\u6709\u7528\u7684\u5217\u8868\u5982\u4e0b\u3002 wge […]<\/p>\n","protected":false},"author":1479,"featured_media":92136,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-150848","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/150848","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1479"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=150848"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/150848\/revisions"}],"predecessor-version":[{"id":150939,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/150848\/revisions\/150939"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/92136"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=150848"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=150848"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=150848"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}