shell 函數法實現監控web 網站url
阿新 • • 發佈:2017-06-03
shll function
使用shell 函數實現監控web 網站url
[[email protected] scripts]# cat checkweb.sh #!/bin/bash function usage() { echo $"usage:$0 url" exit 1 } function check_url() { wget --spider -q -o /dev/null --tries=1 -T 5 $1 if [ $? -eq 0 ] then echo "$1 is yes." else echo "$1 is no." fi } function main() { if [ $# -ne 1 ] then usage fi check_url $1 } main $*
腳本運行如下
[[email protected] scripts]# sh checkweb.sh usage:checkweb.sh url [[email protected] scripts]# sh checkweb.sh www.baidu.com www.baidu.com is yes. [[email protected] scripts]# sh checkweb.sh www.baidu89988.com www.baidu89988.com is no. [[email protected] scripts]#
本文出自 “知識改變命運” 博客,請務必保留此出處http://ahtornado.blog.51cto.com/4826737/1931787
shell 函數法實現監控web 網站url