Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux: How to find the list of daemon processes and zombie processes

I tried checking on Google, but I couldn't find much information related to the actual question.

How do I get a consolidated list of zombie processes and daemon processes? How do I do it on different operating systems. Linux? AIX? Windows?

I am sure that, based on PID, we cannot identify the type of process. Running through a terminal might not help either.

like image 584
kris123456 Avatar asked Aug 01 '13 10:08

kris123456


People also ask

How do I find zombie processes in Linux?

Zombie processes can be found easily with the ps command. Within the ps output there is a STAT column which will show the processes current status, a zombie process will have Z as the status.

How do you check if there are zombie processes?

Testing for Zombie processes Fortunately, this can easily be found using a PS command. There is a STAT column within a PS command that will show the current status of all system processes. The status of a zombie process will display a 'z' in front of it.


2 Answers

Try out this.

ps axo pid,ppid,pgrp,tty,tpgid,sess,comm |awk '$2==1' |awk '$1==$3'

In the above command I used the very properties of a daemon to filter them out, from all of existing processes in Linux.

The parent of a daemon is always Init, so check for ppid 1. The daemon is normally not associated with any terminal, hence we have ‘?’ under tty. The process-id and process-group-id of a daemon are normally same The session-id of a daemon is same as it process id.

like image 67
madala Avatar answered Oct 30 '22 14:10

madala


With GNU ps on Linux:

[

$ ps --version

procps-ng version 3.3.3

]

Zombies:

ps -lA | grep '^. Z'

will get you all zombies (note that the param is lowercase 'L', i.e., 'l' followed by 'A').

Daemons:

As @Barmar said there's no way to get daemons for certain, but a clue that a process is a daemon is that it's not associated with any TTY device. The 12th column of 'ps -Al' output is TTY; the 4th is PID, 14th is the process name. Hence:

ps -lA | awk '$12 == "?" {print $4, $14}'

will get you processes that are possibly daemons; not guaranteed! :)

like image 28
kaiwan Avatar answered Oct 30 '22 12:10

kaiwan