tupac1979
asked on
How to see daemons in ubuntu
I m trying to see if my heartbeat mangement daemon is running what command or is there way to see the daemon running on ubuntu distribution. Thanks
Sorry, small mistake: "pgrep processname" itself already shows the process id. "pgrep -l" also shows the process name, because the normal behavior is to match substrings in the process name. To match only exact names, you can use "pgrep -x processname".
ASKER
Thanks the process name is mgmtd and when I run the command
pgrep -x mgmtd nothing happens. Am I doing something wrong or does that mean the process is not running?
pgrep -x mgmtd nothing happens. Am I doing something wrong or does that mean the process is not running?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The outup is below when I run the command ps- aux | grep mgmtd
Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html
1000 13152 0.0 0.0 3004 772 pts/2 S+ 16:46 0:00 grep mgmtd
Does this mean the daemon is running?
Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html
1000 13152 0.0 0.0 3004 772 pts/2 S+ 16:46 0:00 grep mgmtd
Does this mean the daemon is running?
to have all process running:
ps -A
To check a specific process:
ps -A | grep process_name
ps -A
To check a specific process:
ps -A | grep process_name
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Plus, pgrep is better to use in a script. If "pgrep -x mgmtd" exits with exit value 0, you can be sure a process with process name "mgmtd" is running. If you do the same with "ps aux | grep mgmtd", it will always return 0.
Try it ("echo $?" will return the exit value of the previous command):
pgrep -x mgmtd; echo $?
pgrep -x qwertzuiopasdfghjkl; echo $? (should return 1, because there's no such process)
ps aux | grep mgmtd; echo $?
ps aux | grep qwertzuiopasdfghjkl; echo $? (will return 0, even though there's no such process)
Try it ("echo $?" will return the exit value of the previous command):
pgrep -x mgmtd; echo $?
pgrep -x qwertzuiopasdfghjkl; echo $? (should return 1, because there's no such process)
ps aux | grep mgmtd; echo $?
ps aux | grep qwertzuiopasdfghjkl; echo $? (will return 0, even though there's no such process)
pgrep -l processname