shell 函数法实现监控web 网站url
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了shell 函数法实现监控web 网站url相关的知识,希望对你有一定的参考价值。
使用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的主要内容,如果未能解决你的问题,请参考以下文章