How can I find out, which jar-files java is currently running (and their PIDs)?

con-f-use

I have a .jar file which is notorious for malfunctions. When a malfunction occurs, only a restart helps. I have a way to detect that malfunctions (reading the log-file of said .jar) So I want to write a script, that kills the process whenever the malfunction occurs. The problem is:

confus@confusion:~$ ps -A
...
4438 ?        00:00:00 java
4439 ?        00:00:00 java
4443 ?        00:00:00 java
...

The process name of all running .jars is naturally "java". How do I find out, which of these "java"-processes is the one I want to kill, i.e. the one running foobar.jar?

Egil

You can run the lsof command, which lists which processes has open files, with your jar file given as an argument. An example viewing a file with less:

egil@mutter:~$ lsof foo.c
COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF     NODE NAME
less    18871 egil    4r   REG    8,2        0 53862540 foo.c
egil@mutter:~$

To easily reuse the pid in a script, you could run it in terse mode:

egil@mutter:~$ lsof -t foo.c
18871

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I find out, which jar-files java is currently running (and their PIDs)?

From Java

Tmux: How do I find out the currently running version of tmux?

From Dev

How can I find out which version of Zurb Foundation I'm running

From Dev

How can I find out which version of Zurb Foundation I'm running

From Dev

How can I find out which version of Cassandra a specific DSE is running?

From Dev

How can I visually find out which programs are running on the current virtual screen in Unity?

From Dev

How can I find out which version of Microsoft Internet Information Services (IIS) my server is running?

From Java

Given two directory trees, how can I find out which files differ by content?

From Dev

How can I find out in git which files are different between branches?

From Dev

How can I find out which files are lost through a ddrescue recovery atempt?

From Dev

How can I find out which PID belongs to which script?

From Dev

How can I find out which index is out of range?

From Dev

If I've installed an application both as a snap and via APT, how can I tell which one is currently running?

From Dev

How do I find out which string resource is currently assigned to the android:text property of a button view?

From Dev

how do i find out which network profile is currently connected to wifi using netsh command on windows

From Dev

How can I find out what distro I am running?

From Dev

How can I work out which user is currently logged into a Windows 7 machine?

From Dev

How to find out which file is currently written by a process

From Dev

How to find out which file is currently opened in vim?

From Dev

How to find out whether Hyper-V is currently enabled/running

From Dev

How can I find which drive my exe is running from?

From Dev

How can I find which version of CoreOS is running on a given machine

From Dev

How can I find which drive my exe is running from?

From Dev

How can I find out which parameters a route has in php

From Dev

How can I find out which method of a derived class is not implemented?

From Dev

How can I find out which library is including libcmt?

From Dev

How can I find out which table a foreign key references?

From Dev

How can I find out which Git commits cause conflicts?

From Dev

How can I find out which users are in a group within Linux?

Related Related

  1. 1

    How can I find out, which jar-files java is currently running (and their PIDs)?

  2. 2

    Tmux: How do I find out the currently running version of tmux?

  3. 3

    How can I find out which version of Zurb Foundation I'm running

  4. 4

    How can I find out which version of Zurb Foundation I'm running

  5. 5

    How can I find out which version of Cassandra a specific DSE is running?

  6. 6

    How can I visually find out which programs are running on the current virtual screen in Unity?

  7. 7

    How can I find out which version of Microsoft Internet Information Services (IIS) my server is running?

  8. 8

    Given two directory trees, how can I find out which files differ by content?

  9. 9

    How can I find out in git which files are different between branches?

  10. 10

    How can I find out which files are lost through a ddrescue recovery atempt?

  11. 11

    How can I find out which PID belongs to which script?

  12. 12

    How can I find out which index is out of range?

  13. 13

    If I've installed an application both as a snap and via APT, how can I tell which one is currently running?

  14. 14

    How do I find out which string resource is currently assigned to the android:text property of a button view?

  15. 15

    how do i find out which network profile is currently connected to wifi using netsh command on windows

  16. 16

    How can I find out what distro I am running?

  17. 17

    How can I work out which user is currently logged into a Windows 7 machine?

  18. 18

    How to find out which file is currently written by a process

  19. 19

    How to find out which file is currently opened in vim?

  20. 20

    How to find out whether Hyper-V is currently enabled/running

  21. 21

    How can I find which drive my exe is running from?

  22. 22

    How can I find which version of CoreOS is running on a given machine

  23. 23

    How can I find which drive my exe is running from?

  24. 24

    How can I find out which parameters a route has in php

  25. 25

    How can I find out which method of a derived class is not implemented?

  26. 26

    How can I find out which library is including libcmt?

  27. 27

    How can I find out which table a foreign key references?

  28. 28

    How can I find out which Git commits cause conflicts?

  29. 29

    How can I find out which users are in a group within Linux?

HotTag

Archive