Link to home
Start Free TrialLog in
Avatar of tupac1979
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
Avatar of wilhelm_voigt
wilhelm_voigt
Flag of Austria image

Do you know the process name? You can check for running processes using the "pgrep" command, e. g. to see the process id:

pgrep -l processname
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".
Avatar of tupac1979
tupac1979

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?

ASKER CERTIFIED SOLUTION
Avatar of michofreiha
michofreiha
Flag of Lebanon image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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?
to have all process running:
ps -A
To check a specific process:
ps -A | grep process_name
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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)