Skip to content

Find the Process Causing High CPU Usage on Raspberry Pi

If your Raspberry Pi is slow or the fan keeps spinning, run top over SSH while the problem is happening. Sort by CPU usage, watch which process stays at the top, and use its PID to find the program or service behind it.

Find high CPU usage with top

1
2
3
# See recent system load, then watch processes live.
uptime
top
  1. Press uppercase P to sort by CPU usage.
  2. Watch a few refreshes while the Pi is slow. Write down the PID and COMMAND of any process that repeatedly appears near the top.
  3. Press 1 to switch between the combined CPU summary and per-core readings. Press q to quit.

In the usual Irix mode, a process at 100% is using about one logical CPU's worth of time. On a four-core Pi 4, that is about a quarter of total CPU capacity. A multithreaded process can exceed 100% in this mode. The summary at the top reports CPU time across the board when the per-core view is off. top manual

The three load averages from uptime cover 1, 5, and 15 minutes. They include runnable tasks and tasks in uninterruptible waits, such as some storage operations. If load is high while the CPU spends time in I/O wait (wa), check storage and other sources of slowdown. Linux load average manual

Check the same process with top and ps

Replace 1234 with the PID you wrote down. Read the second top sample for CPU usage over the one-second refresh interval.

1
2
3
4
# Replace 1234 with the PID from the live view.
pid=1234
top -b -d 1 -n 2 -p "$pid"
ps -p "$pid" -o pid,ppid,etimes,stat,pcpu,comm

ps gives you the parent PID (PPID), elapsed time in seconds, and the process's average CPU usage since it started. If the process spent most of its life idle and just became busy, the ps percentage can be much lower than the latest top reading. ps manual

On a Pi 4B running Trixie, a test Python process slept for five seconds and then ran a single busy loop. During the loop, top showed 100.0% for python3, while ps reported 21.6% over the life of the process so far. The combined CPU summary showed 74.8% idle at the second refresh.

Trace the PID to a systemd service

Run this in the same shell, with pid still set to the process you found.

# Ask the system manager which unit contains the PID.
systemctl status "$pid" --no-pager

If the result is user@1000.service or a similar user manager unit, check which user unit owns the process. Run the following as the same logged-in user that owns the process.

1
2
3
# Ask your user manager, then print the process's cgroup path.
systemctl --user status "$pid" --no-pager
cat "/proc/$pid/cgroup"

On the test Pi, the system manager returned the user manager unit, and the user manager returned the specific temporary service. A scope such as session-3.scope can point to a login session, so use the process name and parent PID to narrow it down. If the process has already exited, return to the live top view and catch its next occurrence. systemctl manual

Keep checking the symptom

Donate