Меню Рубрики

Linux defunct process kill

How to kill linux defunct process by shell script [closed]

Want to improve this question? Update the question so it’s on-topic for Stack Overflow.

Closed 8 years ago .

In my server machines some process goes to defunct state for every day. it affects my CPU usage. Need to write a shell script to kill the defunct process id and parent id.

For example, when i run the command:

found may values. In that i need to kill only «[chrome] defunct» process.

I need to kill this type of chrome entries. Can any one suggest some samples to kill the entries

2 Answers 2

Defunct processes do not go away until the parent process collects the corpse or the parent dies. When the parent process dies, the defunct processes are inherited by PID 1 (classically it is PID 1; it is some system process designated with the job), and PID 1 is designed to wait for dead bodies and remove them from the process table. So, strictly, the defunct processes only go away when their parent collects the corpse; when the original parent dies, the new parent collects the corpse so the defunct process goes away at last.

So, either write the parent code so that it waits on its dead children, or kill the parent process.

Note that defunct processes occupy very little resources — basically, a slot in the process table and the resource (timing) information that the parent can ask for. Having said that, last year I was working on a machine where there were 3 new defunct processes per minute, owned by a a system process other than PID 1, that were not being harvested. Things like ps took a long, long, long time when the number of defunct processes climbed into the hundreds of thousands. (The solution was to install the correct fix pack for the o/s.) They are not completely harmless, but a few are not a major problem.

Источник

Killing a defunct process on UNIX system [closed]

Want to improve this question? Update the question so it’s on-topic for Stack Overflow.

Closed 7 years ago .

I have a defunct process on my system:

How can I kill the above process, without a reboot of the machine? I have tried with

5 Answers 5

You have killed the process, but a dead process doesn’t disappear from the process table until its parent process performs a task called «reaping» (essentially calling wait(3) for that process to read its exit status). Dead processes that haven’t been reaped are called «zombie processes.»

The parent process id you see for 31756 is process id 1, which always belongs to init . That process should reap its zombie processes periodically, but if it can’t, they will remain zombies in the process table until you reboot.

Did you check for a child process that may need to be killed first? Sometimes the jam up is down the line. Try ps -ef —forest

to see what may be below it (if anything) then kill that first, then the one you already know about

If kill -9 fails to kill a process the cause is almost always a driver or operating system bug.

The init process has adopted the process, but it cannot reap it. That is to say: when init calls wait(2) that process is not returned. One of the primary purposes of init is to reap dead orphaned children, so the problem is not that its parent died before it was reaped. Think: Otherwise, who reaps the results of a nohup’d process after logout?

Killing children of the defunct process is unlikely to help unless they are somehow related to the particular bug you are seeing.

Источник

What is a process, and why doesn’t it get killed?

The chrome browser was not responsive and I tried to kill it, but instead of disappearing the process had at its right, and didn’t get killed:

What is for a process and why it doesn’t it get killed?

6 Answers 6

From your output we see a «defunct», which means the process has either completed its task or has been corrupted or killed, but its child processes are still running or these parent process is monitoring its child process. To kill this kind of process, kill -9 PID doesn’t work. You can try to kill them with this command but it will show this again and again.

Determine which is the parent process of this defunct process and kill it. To know this run the command:

ps -ef | grep defunct

Then kill -9 637 27872 , then verify the defunct process is gone by ps -ef | grep defunct .

Processes marked are dead processes (so-called «zombies») that remain because their parent has not destroyed them properly. These processes will be destroyed by init(8) if the parent process exits.

You can’t kill it because it is already dead. The only thing left is an entry in the process table:

On Unix and Unix-like computer operating systems, a zombie process or defunct process is a process that has completed execution but still has an entry in the process table. This entry is still needed to allow the parent process to read its child’s exit status.

There is no harm in letting such processes be unless there are many of them. Zombie is eventually reaped by its parent (by calling wait(2) ). If original parent hasn’t reaped it before its own exit then init process ( pid == 1 ) does it at some later time. Zombie Process is just:

A process that has terminated and that is deleted when its exit status has been reported to another process which is waiting for that process to terminate.

Источник

How to kill a process with parent 1

I am running Bacula on a RedHat box. From time to time, the storage daemon bacula-sd stops working and becomes .

My question is, how can I kill this process? Its parent is 1, which is init, as far as I know, and I wouldn’t want to kill the init process, would I?

‘Normally’ killing this process does not work:

Help is greatly appreciated!

produces the following output:

7 Answers 7

The only way you could remove the zombie/defunct process, would be to kill the parent. Since the parent is init (pid 1), that would also take down your system.

This pretty much leaves you with two options.

  • Manually modify the process table, eg. create a dummy process, link the defunct process as a child of the dummy, then kill them off. Quite dangerous, and you may have to manually clean up other process resources such as semaphores and file handles.
  • Reboot the system.

I’d go with the second.

Check if there was a kernel panic,

Check if the process is in «D» Unkillable sleep, where it’s in kernel mode for some syscall which has not returned yet (either kernel oops, or some other reason) http://www.nabble.com/What-causes-an-unkillable-process—td20645581.html

You could try restarting init:

Otherwise, I wouldn’t worry too much. It’s not running and it’s not taking any resources and it’s just there so the kernel can remember it.

If a zombie has init as its parent, then init has stopped working properly. One of the roles of init is to clean up zombies. If it doesn’t do it, noone else will. So the only solution is to reboot. If init is broken, then a reboot may fail, so I’d shut down important services, sync the filesystem then hit the power button instead.

Let’s keep the panic down, shall we? A «defunct» or «zombie» process is not a process. It is simply an entry in the process table, with a saved exit code. Thus, a zombie holds no resources, takes no CPU cycles, and uses no memory, since it is not a process. Don’t get all weird and itchy trying to «kill» zombie processes. Just like their namesakes, they can’t be killed, since they’re already dead. But unlike the brain-eating kind, they harm absolutely no-one, and won’t bite other processes.

Don’t let zombie processes eat your brain. Just ignore them.

Источник

Linux defunct process kill

Welcome to LinuxQuestions.org, a friendly and active Linux Community.

You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!

Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.

Are you new to LinuxQuestions.org? Visit the following links:
Site Howto | Site FAQ | Sitemap | Register Now

If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.

Having a problem logging in? Please visit this page to clear all LQ-related cookies.

Introduction to Linux — A Hands on Guide

This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter. For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author’s experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *

  • Mac os какие файловые системы поддерживает
  • Mac os какие игры идут
  • Mac os какая система лучше
  • Mac os как читается
  • Mac os как установить обои на рабочий стол