检查Web应用是否启动

发布于 2025-01-05 23:58:08 字数 150 浏览 2 评论 0原文

我想编写一个脚本来使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

寄意 2025-01-12 23:58:08
  1. 运行 wget 命令,
  2. -O 选项告诉将检索到的数据放在何处
  3. /dev/null 是一个特殊的 UNIX 文件,始终存在空的。换句话说,数据被丢弃。
  4. -q 表示安静。通常 wget 会打印大量信息,告诉其下载数据的进度,因此我们关闭该位。
  5. http://mysite.com 是您要检索的确切网页的 URL。

许多程序员为此目的创建一个特殊的页面,该页面很短并且包含状态数据。在这种情况下,不要丢弃它,而是通过将 -O /dev/null 替换为 -a mysite.log 将其保存到日志文件中。

  1. Run the wget command
  2. the -O option tells where to put the data that is retrieved
  3. /dev/null is a special UNIX file that is always empty. In other words the data is discarded.
  4. -q means quiet. Normally wget prints lots of info telling its progress in downloading the data so we turn that bit off.
  5. 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.

红玫瑰 2025-01-12 23:58:08

检查您是否可以连接到您的网络服务器。

  1. 连接到您的 Web 服务器所在的端口
  2. 如果连接正确,则您的 Web 服务器已启动,否则已关闭。
  3. 你可以进一步检查一下。 (例如,如果索引页正确)

请参阅此 shell 脚本。

if wget -O /dev/null -q http://shiplu.mokadd.im; 
then 
    echo Site is up
else 
    echo Site is down
fi

Check whether you can connect to your web server.

  1. Connect to the port where you web server
  2. If it connects properly your web server is up otherwise down.
  3. You can check farther. (e.g. if index page is proper)

See this shell script.

if wget -O /dev/null -q http://shiplu.mokadd.im; 
then 
    echo Site is up
else 
    echo Site is down
fi
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文