How to check if a pid is alive?

Hi,

I have a process which is running in background and I want a simple command to find if the process id still running?

How to check if a pid is alive?

Thanks

View Answers

July 18, 2015 at 2:13 AM

HI,

You can use the following command:

ps -ef | grep <pid> | grep -v grep

For example process id if the process is: 3447 then you can use the following command

ps -ef | grep 3447 | grep -v grep

and will give output something like this:

[root@localhost ~]# ps -ef | grep 3447 | grep -v grep
avahi     3447     1  0 13:17 ?        00:00:00 avahi-daemon: running [localhost.local]
avahi     3448  3447  0 13:17 ?        00:00:00 avahi-daemon: chroot helper
[root@localhost ~]#

Hope this solves your problem.

Thanks









Related Tutorials/Questions & Answers:
Advertisements