Search code examples
linuxcommandps

Linux ps Output Format Spec


I am using Java API to connect my Remote Machine so I can see the running processes.

One of the requirements is to be able to kill any of the processes.

Now I am executing command

ps aux | grep java which return list of the running processes.

eg.

root       330  0.2  0.0     0    0 pts/0    Z    08:42   0:11 [java] 

Does anyone know what is the spec is used for above output ? I'll need to convert above line into an object where 330 will the process id.


Solution

  • If you are only intresseted in the pid of the processes with that name check pgrep.


    Example:

    $ pgrep sshd
    791
    22956
    23060