检查Windows服务是否正在运行 [英] Check if a Windows service running

查看:72
本文介绍了检查Windows服务是否正在运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以编程方式检查某项服务是否运行是否很好的方法?


我们有定期服务的服务,我需要检查看看这个

服务是否正在运行。我知道如何查看状态是否已停止

或运行模式。但是这并没有告诉我它是否真的在运行。


我需要知道这一点,如果它发生了,我可以通过编程方式启动

在另一台机器上提供服务。


我想做的是建立一项服务,定期检查

(大约每分钟一次),看看是否有其他的服务实际上正在运行。


谢谢,


Tom

What would be a good way to check programmatically whether a service was
running?

We have a service that dies periodically and I need to check to see if this
service is running. I know how to check to see if the status is in stopped
or running mode. But that doesn''t tell me if it is actually running.

I need to know this so that if it happens I can programmatically start the
same service on another machine.

What I would like to do is build a service that just periodically checks
(about once a minute) to see if the other service is actually running.

Thanks,

Tom

推荐答案

你好tshad,


如果你不是服务的作者,你肯定不知道运行它

或不是,因为例如web -Methods服务器服务在服务设置运行20分钟后开始真正运行

状态。


检查它是否运行的唯一方法是检查文件/环境

服务控制


t以编程方式检查服务是否运行的好方法是什么?

t>

我们有定期服务的服务我需要查看

如果此服务正在运行。我知道如何检查状态

是处于停止还是运行模式。但是那并没有告诉我是否在战术上运行。

t>

我需要知道这一点,以便在发生时我可以通过编程方式

在另一台机器上启动相同的服务。

t>

我想做的是建立一个定期服务

tchecks(大约每分钟一次)看看其他服务是否真的是

trunning。

t>

tThanks,

t>

tTom

t>

---

WBR,

Michael Nemtsev ::博客: http://空格.msn.com / laflour


有时一个人仍忠于某一事业只是因为它的对手没有

不再是平淡无奇的" (c)Friedrich Nietzsche
Hello tshad,

If you are not the author of service you definitely can''t know running it
or not, because for example web-Methods Server services start really running
after 20 mins as service set "running" status.

The only way to check whether it run is to check that files/environment that
service control

tWhat would be a good way to check programmatically whether a service
twas running?
t>
tWe have a service that dies periodically and I need to check to see
tif this service is running. I know how to check to see if the status
tis in stopped or running mode. But that doesn''t tell me if it is
tactually running.
t>
tI need to know this so that if it happens I can programmatically
tstart the same service on another machine.
t>
tWhat I would like to do is build a service that just periodically
tchecks (about once a minute) to see if the other service is actually
trunning.
t>
tThanks,
t>
tTom
t>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche


" Michael Nemtsev" < ne ***** @ msn.com写在留言中

新闻:9c ************************* *@msnews.microsoft .com ...
"Michael Nemtsev" <ne*****@msn.comwrote in message
news:9c**************************@msnews.microsoft .com...

你好tshad,


如果你不是服务的作者你肯定不知道运行它

与否,因为例如web-Methods服务器服务真的开始运行20分钟后运行服务集运行状态。
Hello tshad,

If you are not the author of service you definitely can''t know running it
or not, because for example web-Methods Server services start really
running after 20 mins as service set "running" status.



我是该服务的作者。


但是我有一项服务可以发送在运行模式下显示的电子邮件并且由于某种原因,它每隔5或6天就会死掉一次并且似乎被冻结了(可能会无限循环 - 但是我无法找到它会发生)。服务窗口中的

状态或当我从另一个程序请求它时

显示它正在运行(如果它从未点击停止代码,那将是有意义的。


我需要找一个很好的方法来监控它是否已经停止

(直到我能找到代码的问题)。


顺便说一句,当我到达这一点时,我根本无法停止程序。我需要

重新启动服务器以释放它。 />

I am the author of the service.

But I have a service that sends out emails that shows in running mode and
for some reason it dies once every 5 or 6 days and seems to be frozen (could
be in an infinite loop - but I can''t find where that would happen). The
status in the services windows or when I request it from another program
shows it as running (which would make sense if it never hit the Stop code.

I need to find a good way to monitor it to tell if it has stopped or not
(until I can find the problem with the code).

BTW, when I get to this point, I can''t stop the program at all. I need to
reboot the server to get it released.


>

检查它是否运行的唯一方法是检查文件/环境

该服务控制
>
The only way to check whether it run is to check that files/environment
that service control



不确定你的意思。


谢谢,


Tom

Not sure what you mean here.

Thanks,

Tom


t以编程方式检查服务是否运行的好方法是什么?

tt我们有一个定期去世的服务,我需要查看

这项服务在跑。我知道如何检查状态

是处于停止还是运行模式。但是那并没有告诉我它是否在战术上运行。

tt我需要知道这一点,如果它发生我可以通过编程方式

在另一台机器上启动相同的服务。

tt我想做的是建立一项服务,只需定期

tchecks(大约每分钟一次),看看是否另一台服务实际上是

trunning。

tt谢谢,

ttTom

t ---

WBR,

Michael Nemtsev ::博客: http:// spaces.msn.com/laflour


有时一个人仍然忠实于一个事业只因为它的对手做了

不停止是平淡"。 (c)Friedrich Nietzsche

tWhat would be a good way to check programmatically whether a service
twas running?
ttWe have a service that dies periodically and I need to check to see
tif this service is running. I know how to check to see if the status
tis in stopped or running mode. But that doesn''t tell me if it is
tactually running.
ttI need to know this so that if it happens I can programmatically
tstart the same service on another machine.
ttWhat I would like to do is build a service that just periodically
tchecks (about once a minute) to see if the other service is actually
trunning.
ttThanks,
ttTom
t---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do
not cease to be insipid." (c) Friedrich Nietzsche



你好tshad,


我''我不确定如此残酷的方式来解决您的服务是一种好方法:)


为什么不进行一些内部检查,例如是否发送电子邮件或

不是或者例如每天午夜重启服务。


t" Michael Nemtsev" < ne ***** @ msn.com写信息

tnews:9c ************************* *@msnews.microsof.com.cn

t>
Hello tshad,

I''m not sure that such brutal way to fix you service is a good way :)

Why not to make some internal check, for example whether email was send or
not or for example each day in midnight restart service.

t"Michael Nemtsev" <ne*****@msn.comwrote in message
tnews:9c**************************@msnews.microsof t.com...
t>

> Hello tshad,

如果你不是服务的作者,你绝对可以''知道运行与否,因为例如web-Methods服务器服务在服务集运行20分钟后开始真正运行。状态。
>Hello tshad,

If you are not the author of service you definitely can''t know
running it or not, because for example web-Methods Server services
start really running after 20 mins as service set "running" status.



我是该服务的作者。

t>

t但我有一项服务,发送显示在运行模式的电子邮件

由于某种原因,它每5或6天死一次,似乎是

tfrozen(可能在一个无限循环 - 但我找不到那个

会发生的事情)。服务窗口中的状态或当我从另一个程序请求

tit时显示它正在运行(这是有意义的

如果它从未点击停止代码。

t>

我需要找到一个很好的方法来监控它是否已经停止或

tnot(直到我能找到问题所以代码)。

t>

tBTW,当我到达这一点时,我根本无法停止该程序。我

tneed重新启动服务器以释放它。

t>

tI am the author of the service.
t>
tBut I have a service that sends out emails that shows in running mode
tand for some reason it dies once every 5 or 6 days and seems to be
tfrozen (could be in an infinite loop - but I can''t find where that
twould happen). The status in the services windows or when I request
tit from another program shows it as running (which would make sense
tif it never hit the Stop code.
t>
tI need to find a good way to monitor it to tell if it has stopped or
tnot (until I can find the problem with the code).
t>
tBTW, when I get to this point, I can''t stop the program at all. I
tneed to reboot the server to get it released.
t>


>唯一的方法是检查是否运行是检查
文件/环境即服务控制
>The only way to check whether it run is to check that
files/environment that service control



t不确定你的意思。

t>

t谢谢,

t>

tTom

t>

tNot sure what you mean here.
t>
tThanks,
t>
tTom
t>


> t以编程方式检查的好方法运行服务
twas运行?
我们有定期服务的服务,我需要检查
如果这项服务正在运行。我知道如何检查
状态是否处于停止或运行模式。但这并没有告诉我它是否在机上运行。
我需要知道这一点,如果它发生我可以编程方式在另一台机器上启动相同的服务。
tt我想做的是建立一个服务,只是定期(大概每分钟一次)检查其他服务是否实际上是否真的好运。
ttThanks,
ttTom
t ---
WBR,
Michael Nemtsev ::博客: http://spaces.msn.com/laflour
有时候一个人仍然忠于一个事业只因为它的对手不要停止平淡。 (c)Friedrich Nietzsche
>tWhat would be a good way to check programmatically whether a
service
twas running?
ttWe have a service that dies periodically and I need to check to
see
tif this service is running. I know how to check to see if the
status
tis in stopped or running mode. But that doesn''t tell me if it is
tactually running.
ttI need to know this so that if it happens I can
programmatically
tstart the same service on another machine.
ttWhat I would like to do is build a service that just
periodically
tchecks (about once a minute) to see if the other service is
actually
trunning.
ttThanks,
ttTom
t---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents
do not cease to be insipid." (c) Friedrich Nietzsche



---

WBR,

Michael Nemtsev ::博客: http://spaces.msn.com/laflour


有时一个人仍然忠实于一个事业只因为它的对手不会因为b $ b不再是平淡的。 (c)Friedrich Nietzsche

---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche


这篇关于检查Windows服务是否正在运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆