>_ IzzyLab

Hands-on task

This task is step 4 of the course “Running a server”

Find the process eating your CPU

medium~5 min

The server is crawling: some process is pinning the CPU at full tilt. Find the greediest one and kill it — but don't touch the other working processes (for example, the worker daemon must survive your cleanup).

What you'll practise:
  • ps
  • pgrep
  • kill
  • cpu monitoring
  • process management

Topic breakdown

Diagnosing a greedy process starts with an overview of the process table: ps aux shows a %CPU column, and sorting by that field in descending order (the --sort key) raises the culprit to the top; the interactive alternative is top with CPU sorting. Each process is identified by a numeric PID, by which it can be terminated with a signal (kill), or addressed by name via pkill/pgrep — which have an exact-name-match flag so you don't hit namesakes. The key idea of this task is to strike the culprit precisely, without touching the neighboring working processes.

What's checked

  1. the most resource-hungry process is killed
  2. worker daemon is alive

What it looks like