Profile a Single Process with pidstat

pidstat prints time-series CPU, memory, and I/O statistics for one PID (or all tasks), ideal for capturing a process's behavior over minutes.

LinuxProcessesperformancepidstatLow risk
Run `pidstat -u -r -d -p <PID> 2 5` to sample that process's CPU, memory, and I/O statistics every 2 seconds for 5 samples; omit -p to monitor every task.

01Command

Command
$ pidstat -u -r -d -p 1234 2 5

02What it does

top gives a momentary snapshot, but pidstat produces interval samples you can log or diff, which makes it the tool for profiling a specific PID. -u adds CPU (%usr, %system), -r memory (RSS, major faults), and -d I/O (kB_read/s, kB_wrtn/s); combine them in one command as shown. Without -p it reports every task and flags dead ones; `pidstat -G <name>` filters by process name instead of PID.

03Risk

RiskLow risk
Requirementssysstat package (apt install sysstat / dnf install sysstat).

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • pidstat(1) - Report statistics for Linux tasks
    Ubuntu Manpages · technical · 2026-09-17
    Evidence: pidstat reports statistics for Linux tasks (processes): -u CPU usage, -r memory, -d I/O, -p selects a task, with interval and count arguments.

Last verified: 2026-09-17 · Category: System & Settings

06Related solutions