问题
昨天同事在启动job的时候怎么也启动不了, ps aux|grep java 结果出来一大堆,看着眼花缭乱的,这台服务器用main方法启动job,近几十个,所以想尽快的找到自己的job变得很困难,或者是通过job的名称来找,这就需要我们能记住job名称并且要命名规范,有一种方式能尽快找到自己想要的job进程的pid号,直接杀掉再操作就可以了。
linuxpid 简介
1. short for product identification or product id,PID is a unique number that helps identify a hardware product or a registered software product .
2.Short for process identifier , a PID is unique number that identifier each of the running processes in an operating system such as Linux , Unix ,Mac OS X, and Microsoft Windows . In the below output , is an example of a few of the processes running in Windows and their associated PID's listed in the PID column .
PID 是各进程的代号,每个进程有唯一的PID编号。它是进程运行时系统分配的,并不代表专门的进程。在运行时PID是不会改变标识符的,但是进程终止后PID标识符就会被系统回收,就有可能被继续分配给新的运行程序。
问题解决思路
可以为启动的job定义自己的pid文件的存放位置,这样这个文件中存储的就是这个进程唯一的PID,这样直接打开指定位置的pid文件,直接kill这个pid号就可以了,省去了 ps aux|grep java ,再去找这个pid,省去这个步骤。
解决过程
Java -jar Test.jar & #注意:必须有&让其后台执行,否则没有pid生成
echo $! > /usr/local/bgtask/Test.pid # 将jar包启动对应的pid写入文件中,为停止时提供pid
1490

被折叠的 条评论
为什么被折叠?



