检查Web应用是否启动
我想编写一个脚本来使用 unix shell 脚本检查应用程序是否启动。
通过谷歌搜索,我发现了一个脚本 wget -O /dev/null -q http://mysite.com
,但不确定它是如何工作的。有人可以解释一下吗?这对我会有帮助。
I would like to write a script to check whethere the application is up or not using unix shell scripts.
From googling I found a script wget -O /dev/null -q http://mysite.com
, But not sure how this works. Can someone please explain. It will be helpful for me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
wget
命令,-O
选项告诉将检索到的数据放在何处/dev/null
是一个特殊的 UNIX 文件,始终存在空的。换句话说,数据被丢弃。-q
表示安静。通常 wget 会打印大量信息,告诉其下载数据的进度,因此我们关闭该位。http://mysite.com
是您要检索的确切网页的 URL。许多程序员为此目的创建一个特殊的页面,该页面很短并且包含状态数据。在这种情况下,不要丢弃它,而是通过将
-O /dev/null
替换为-a mysite.log
将其保存到日志文件中。wget
command-O
option tells where to put the data that is retrieved/dev/null
is a special UNIX file that is always empty. In other words the data is discarded.-q
means quiet. Normally wget prints lots of info telling its progress in downloading the data so we turn that bit off.http://mysite.com
is the URL of the exact web page that you want to retrieve.Many programmers create a special page for this purpose that is short, and contains status data. In that case, do not discard it but save it to a log file by replacing
-O /dev/null
with-a mysite.log
.检查您是否可以连接到您的网络服务器。
请参阅此 shell 脚本。
Check whether you can connect to your web server.
See this shell script.