Ubuntu Java:找到特定程序的pid并杀死该程序 [英] Ubuntu Java: Find a specific program's pid and kill the program
本文介绍了Ubuntu Java:找到特定程序的pid并杀死该程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试制作一个应用程序,该应用程序检查该特定应用程序是否正在运行,然后在指定的时间后将其终止.我打算获取该应用程序的pid.如何获取应用程序的pid?
I'm trying to make an application that checks if this specific application is running, then kill the app after a specified amount of time. I'm planning to get the pid of the app. How can I get the pid of the app?
谢谢
推荐答案
您可以尝试ps -aux | grep foobar
获取pid,然后对它发出kill
命令,或者您可能要使用
You might try ps -aux | grep foobar
for getting the pid, then issuing the kill
command against it, alternatively you might want to use pkill
foobar
, in both cases foobar
being the name of the app you want to terminate.
这篇关于Ubuntu Java:找到特定程序的pid并杀死该程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文