简体   繁体   English

PowerShell-检查Java应用程序是否正在运行,如果没有运行,请重新启动它。 (Javaw.exe不显示详细信息)

[英]PowerShell - Check if Java Application is running, if not - restart it. (Javaw.exe doesn't show details)

I've had a good search around, but can't quite find what I'm looking for. 我在周围搜索了很好,但是找不到我想要的东西。

We have Java applications running 24/7 on several remote machines which intermittently crashes (We think the application's devs are working on it) but for the time being, we need a way of restarting this application should it fail. 我们有Java应用程序在几台远程机器上以24/7的速度运行,这些机器间歇性地崩溃(我们认为该应用程序的开发人员正在为此工作),但是暂时,我们需要一种在失败时重新启动该应用程序的方法。

Now... the tricky thing is, as far as I can see at least, is that there's no way of telling if the application is running at all as only Javaw.exe shows in task manager. 现在,至少在我看来,棘手的事情是,无法像任务管理器中仅显示的Javaw.exe那样告诉应用程序是否正在运行。 Even with the command line column, it only points to javaw.exe. 即使使用命令行列,它也仅指向javaw.exe。

The reason we can't just check if Javaw is running, is because we have another Java application that isn't used as much (it's like a web based CRM software) This also starts Javaw.exe when needed, and also doesn't show up as a process. 我们不能仅仅检查Javaw是否正在运行的原因是,因为我们有另一个Java应用程序的使用率不高(就像基于Web的CRM软件一样),这在需要时也会启动Javaw.exe,并且也不会显示为一个过程。

It would be easy enough to just restart the Javaw.exe, if it didn't cause horrendous problems to the CRM side of things. 如果它不会对CRM方面造成可怕的问题,只需重新启动Javaw.exe就足够了。

I'm not the best at PowerShell, but do have a grasp of it. 我不是PowerShell方面的佼佼者,但一定要掌握它。 I'm just out of ideas. 我没有主意。

I hope you guys can help. 希望你们能帮上忙。

Thanks for your time. 谢谢你的时间。

ARc

Perhaps this other question may help. 也许这另一个问题可能会有所帮助。 It basically uses jps that is included in JRE/JDK to get more fine grained info of javaw. 它基本上使用JRE / JDK中包含的jps来获取javaw的更多细粒度信息。

You can then parse the output and determine whether the app is still running. 然后,您可以解析输出并确定应用程序是否仍在运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM