Skip to content

Killing Linux Zombie Processes

Tips
  • Periodically, when logging into any Linux based server, you may be met with the below

    32fbb04c-7cf3-4c4a-92df-7c62748f7d07-image.png

    In a typical Linux scenario, a process (or sub process) notifies its parent when it has completed its execution and has exited. The parent process should remove the process from process table. However, if the parent process is unable to read the process status from its child (the completing process or sub process), it won’t be able to remove the this from memory which causes the supposedly dead process to still continue to exist in the process table. The end result of this issue is a “zombie process” - one that has no reason to be running, and should have been terminated.

    Before you can terminate a process, you need to be able to identify it. Run the below in the terminal

    ps aux | egrep "Z|defunct"
    

    Here’s the result

    20274412-e1e1-4ddb-8a94-a659a649c21b-image.png

    Now, you can’t actually “kill” something that is already dead, but you can notify the parent process that it should check again to see if the sub or child process is still running or not

    ps -o ppid= <Child PID>
    

    As an example

    e4df563a-8b5d-4f27-b6db-dd7810fd0689-image.png

    This tells us that the process ID we need to target is 55496. Based on this, we then use

    kill -s SIGCHLD <Parent PID>
    

    49de9c15-e0d1-4077-bab0-801cc13a5c4e-image.png

    And with all the commands together

    5ccb9788-d260-483b-90eb-506ab28c4091-image.png

    Now run

    ps aux | egrep "Z|defunct"
    

    If you still see zombie processes, you’ll need to target the parent process. Please be aware that killing a parent process will automatically kill all child processes, so use with caution.

    21d7cfad-46e9-4638-89e0-32233d7168ad-image.png

    kill -9 <Parent PID>
    

    a4846b3f-fe78-43a2-8169-21e84c181735-image.png

  • @phenomlab

    I test to kill a zombie process on SSH

    ps -o ppid= <Child PID>
    

    the command does not return me any parent process

    167fb778-eb83-49e5-a5a5-45ce03e87504-image.png

    EDIT: Strange things

    When I log into SSH I see the zombie process message

    e26541d3-4fe6-4345-a0ac-aa8e8eb6dd27-image.png

    but not in top :

    3198cec2-e888-4542-9ca9-598803657d58-image.png

    And the zombie process number change with each order cli commands :

    593e5a88-b108-4f56-bf30-e2e4af9346c2-image.png

  • @phenomlab

    I test to kill a zombie process on SSH

    ps -o ppid= <Child PID>
    

    the command does not return me any parent process

    167fb778-eb83-49e5-a5a5-45ce03e87504-image.png

    EDIT: Strange things

    When I log into SSH I see the zombie process message

    e26541d3-4fe6-4345-a0ac-aa8e8eb6dd27-image.png

    but not in top :

    3198cec2-e888-4542-9ca9-598803657d58-image.png

    And the zombie process number change with each order cli commands :

    593e5a88-b108-4f56-bf30-e2e4af9346c2-image.png

    @DownPW odd indeed. Looks like it’s spawning, immediately dying, then spawning again.


Related Topics
  • Arch Linux | Reflector

    Linux
    2
    2 Votes
    2 Posts
    192 Views
    I would like to add that if you type reflector --help in the console you can see the different options you can add to the configuration file. I changed the sort to rate, so the fastest mirrors get used first. I also changed my country to US, because that is where I live and everything else I left default. While doing some research, the Reflector service should fire up about once a week or at boot. It is hooked into pacman so it may refresh when you run the update command above. Location of the config file: /etc/xdg/reflector/reflector.conf
  • Windows 10 End of Life

    General
    10
    2 Votes
    10 Posts
    263 Views
    @phenomlab this looks very nice as well. It is nice that they keep the KDE Neon a rolling release so you will get those updated apps even though Ubuntu isn’t a rolling release. Is it a rolling distro? KDE neon is rolling for KDE software. The Ubuntu base OS is not, but certain packages will be updated as needed to support KDE software requiring newer library versions than what is provided by Ubuntu. Apps from the main repositories are not rolling either, and therefore can be up to two years old. Users are encouraged not to use them, and to instead get apps from Snap or Flatpak using KDE’s Discover app store. In neon, Discover is set up to only show apps from these sources, filtering out apps from the repositories.
  • Arch Server Progress

    Chitchat
    33
    17 Votes
    33 Posts
    1k Views
    @Madchatthew You have a good point about the server needing to be rebooted - specifically after a kernel update, and this is something I’ve noticed on increasing occasions with Ubuntu.
  • 0 Votes
    1 Posts
    1k Views
    No one has replied
  • 1 Votes
    3 Posts
    455 Views
    @Panda said in Wasting time on a system that hangs on boot: Why do you prefer to use KDE Linux distro, over say Ubuntu? A matter of taste really. I’ve tried pretty much every Linux distro out there over the years, and whilst I started with Ubuntu, I used Linux mint for a long time also. All of them are Debian backed anyway I guess I feel in love with KDE (Neon) because of the amount of effort they’d gone to in relation to the UI. I agree about the lead and the OS statement which is why I suspect that Windows simply ignored it (although the Device also worked fine there, so it clearly wasn’t that faulty)
  • 2 Votes
    2 Posts
    418 Views
    As an aside to this, there is also the command of tasklist which will provide a list of processes running on your machine, or a remote machine you are looking to query. [image: 1678806102692-000a408c-cc7e-450f-8e5e-bed9a4238a05-image.png] There is also a useful list of switches below, plus the ability to format into a table, or CSV. https://ss64.com/nt/tasklist.html
  • Environment Variables

    Solved Linux
    8
    1
    1 Votes
    8 Posts
    842 Views
    @madchatthew great you got this to work ! Thanks for the update.
  • 2 Votes
    28 Posts
    3k Views
    @phenomlab said in Advantages and disadvantages of changing to Ubuntu?: @jac Yeah, I wouldn’t just leap into it unless you have a valid reason (such as the laptop no longer working and needing to be reinstalled). Probably better the devil you know currently. Absolutely mate, and generally as discussed that is the only time I have changed over to Ubuntu once the laptop has got slower. For now I will carry on with Windows, purchase the VPN & BitDefender in later October / early November and then see how all that runs for a few more months .