Interview Prep/Linux/Processes, services and systemd

A process is using 100% CPU on a production box. What's your approach before killing it?

BeginnerScenarioProcesses, services and systemd
Answer

Situation read → Understand it before you kill it; it might be important.

What I'd do →

top -c                       # or htop; find PID and command
ps -o pid,ppid,user,etime,cmd -p <PID>
sudo ls -l /proc/<PID>/cwd /proc/<PID>/exe
sudo strace -p <PID> -f -c   # syscalls summary, Ctrl+C after a few seconds

If it's legitimate but should be less greedy: renice +10 -p <PID>. If runaway: kill -TERM, then kill -KILL if it ignores TERM.

Why → SIGTERM lets the app clean up; SIGKILL can leave locks and half-written files.

Interview tip → Grab a thread dump (jstack, py-spy dump) before killing for the postmortem.

All Linux questions Roadmap: Linux

More on Processes, services and systemd