Sikau

Linux and the shell · Day 12 · about 30 min

Processes

ps, top, kill, signals and background jobs.

What is eating the CPU?

Every running program is a process with a number (PID), an owner and a share of CPU and memory. When a server is slow, you find the greedy process and stop it.

Inspect and stop processes

ps
ps aux
top
ps aux | grep node
pgrep -f crunch
kill 1777
ps aux | grep -c crunch
sleep 100 &
jobs
kill 1188
sudo kill 1188

Always try a plain kill first: it lets the program save work and clean up. Use kill -9 only if it ignores you.

The rest of this lesson

  • Reading topexplain
  • Signals and jobsexplain
  • Gentle or forceful?predict
  • Signal or keymatch
  • Your turnwrite code
  • Badge quizquiz
  • What you learnedrecap

Continue this lesson free — run real code in your browser

Continue with Google

See all 16 lessons of Linux and the shell