Command to check if a particular process is running

Hi

What is the best command to check if a particular process is running in a linux server or not

To check any java process, I use the below command.

ps -ef |grep jvm

When I execute the above command, it lists me all the processess . The above command should ideally return only the processess that are running in the server. But even if the particular jvm process is not running/it has been stopped, it gives them as results as well.

Please adivse, How to check this.

U can try below command,
/usr/ucb/ps -axxw | grep java

kill -0

Hi All,

Thanks for the quick response, I tried the below command

/usr/ucb/ps -axxw | grep java

It specified as the file does not exists.

Also I tried the command

kill -0

It did not work. What Im looking for is , a command which will specify whether the process is actually running or not. As specified earlier, when I execute the above ps command, it will actually display all the process even if the particular process is not running. I have to actually check the log files associated with the process to see if the process is running or not. Please Assist. Thanks in advance

I think u can use
"prstat -a "
u will get all running processes.

Plz kindly provide output for below command from ur system.
uname -a

"prstat" and "/usr/ucb/ps" are Solaris commands.

On Linux, you can use the "lsof" command on the binary file. For example:

# lsof /bin/bash
COMMAND   PID    USER  FD   TYPE DEVICE   SIZE    NODE NAME
sh       3125    root txt    REG    8,3 801512 5984927 /bin/bash
bash    14211    root txt    REG    8,3 801512 5984927 /bin/bash

Note the value of the "FD" column. If that's "txt", that means the file is mapped as executable text - in this case, the process is the "bash" process.

Hi

I have executed the command in the server. Please find the below results that I received.

# prstat -a
-bash: prstat: command not found.

---------- Post updated at 05:38 AM ---------- Previous update was at 05:30 AM ----------

Hi

Mine is a Linux system. I tried executing the lsof command and it lists all the process that are running in the system. It seems to work fine. But Im not sure how to identify the binary file. Can you please help me on how to identify the binary file. When I execute the lsof command on the binary file, specified above, I get the below result

lsof /bin/bash
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
run.sh 4711 platrgatxt REG 253,0 773216 65619 /bin/bash
run.sh 4795 platrga txt REG 253,0 773216 65619 /bin/bash
sod.sh 5440 root txt REG 253,0 773216 65619 /bin/bash
bash 6859 vr4637 txt REG 253,0 773216 65619 /bin/bash
bash 6887 root txt REG 253,0 773216 65619 /bin/bash
run.sh 29881 platrga txt REG 253,0 773216 65619 /bin/bash

The above does not seem to list the process that Im intrested in. Please Assist. Thanks