How can I kill the top CPU/IO process quickly?

I locate that occasionally my Linux will certainly stop reacting, so I require to switch over to an additional incurable with CtrlAltF2, and also type a command to kill the top CPU usage process or top IO use process, to make sure that the system can be receptive once more.

This command needs to be brief and also execute promptly. I recognize the command kill, yet I do not recognize just how to get the top - est process PID or name.

I will certainly add this command right into covering pen names or function.

2022-06-07 14:38:29
Source Share
Answers: 2

running top with set setting using -b need to get you the details you are seeking.

Below is a really unpleasant start to what you can do:

top -b -n 1 | head | grep -A 1 PID | grep "^[0-9]" | cut -f1 -d" " | xargs kill

You can constantly kill a process from an interactive run of top making use of the k key too, given that you could not like what it selects

Not certain what bit you are running, yet cgroups might additionally serve to you along with limits.conf

2022-06-07 15:12:25

Keep top or htop operating in an incurable someplace. In top, press k after that enter a PID to kill a process. In htop, relocate the arrow over the process you intend to kill after that press k.

2022-06-07 14:47:45