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.
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.
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.
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.
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! :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With