$linuxjunkies
>

pidstat(1)

Report per-process CPU, memory, I/O, and context switch statistics.

UbuntuDebianFedoraArch

Synopsis

pidstat [OPTION]... [INTERVAL [COUNT]]

Description

pidstat displays resource utilization data for individual processes and tasks running on the system. It reports CPU usage, memory consumption, I/O activity, and context switches per process at regular intervals, making it useful for process-level performance monitoring and troubleshooting.

Part of the sysstat package, pidstat samples process statistics from /proc at the specified interval. Without interval argument, it shows statistics since system boot. With interval and count, it displays multiple snapshots separated by the given time period in seconds.

Common options

FlagWhat it does
-uDisplay CPU utilization (default: user, system, guest, and wait time)
-rDisplay memory page faults and memory usage (RSS, VSZ)
-dDisplay I/O statistics (reads, writes, I/O wait time)
-wDisplay context switch rates (voluntary and involuntary)
-p PIDMonitor specific process ID (comma-separated for multiple PIDs)
-C patternMonitor only processes matching command name pattern
-T {TASK|CHILD|ALL}Report for specific task/thread type; ALL shows all threads
-HDisplay statistics for process and all its threads
--humanDisplay numbers in human-readable format (KB, MB, GB)
-eDisplay command name and all arguments (full command line)
-tInclude timestamp in each line of output

Examples

Show CPU stats for all processes every 1 second for 5 samples

pidstat 1 5

Monitor CPU usage of process 1234 at 1-second intervals

pidstat -u -p 1234 1

Display memory stats for all Java processes every 2 seconds for 10 samples

pidstat -r -C java 2 10

Show I/O statistics for process 5678 over 3 one-second intervals

pidstat -d -p 5678 1 3

Monitor context switches for process 9999 and all its threads

pidstat -w -T ALL -p 9999 1

Display CPU, memory, and I/O stats for all processes every 2 seconds continuously

pidstat -u -r -d 2 0

Related commands