pidstat

pidstat helps monitoring processes on their CPU, memory, and disk activity

Typical usage: performance monitoring, system administration, troubleshooting

Installation

When pidstat is not installed by default, it can be added to the system using the relevant software package.

Package information for pidstat

Operating systemPackage nameInstallation
AlmaLinuxsysstat
dnf install sysstat
Arch Linuxsysstat
pacman -S sysstat
Debiansysstat
apt install sysstat
Fedorasysstat
dnf install sysstat
Red Hat Enterprise Linuxsysstat
dnf install sysstat
Rocky Linuxsysstat
dnf install sysstat
Ubuntusysstat
apt install sysstat

Your Linux distribution using a different package? Share your feedback.

Usage

Available options

OptionDescription
-C NAMEDefine task(s) to monitor, may be using regular expression
-dShow disk activity
--dec=0|1|2Set number of decimals, with 2 being the default
-e COMMAND ARGSExecute a COMMAND (with arguments ARGS) and monitor it with pidstat
-G NAMEDefine process name(s) to monitor, may be using regular expression, can be used with -t
-HInclude timestamp (seconds since epoch)
-hDo not include summary, all output on one line, making it easier to parse by external tools
--humanHuman-readable formats
-IDivide CPU usage by total number of processors, for SMP environments
-lInclude full command and arguments
-p { pid[,pid2,pid3] | SELF | ALL}Monitor only one process, multiple processes, pidstat itself, or all
-RShow information about realtime priority and scheduling
-rShow page faults and memory usage
-sShow stack usage
-T { TASK, CHILD, ALL}Define what should be included for tasks.
-tInclude threads with selected tasks, can be used with -G
-UShow username instead of UID
-uShow CPU usage statistics
-VShow version number
-vShow information about some kernel tables
-wShow task switching activities

Missing an option in this overview? Share your feedback.

Examples using pidstat

CPU usage monitoring with interval

Run pidstat with interval of 3 seconds

pidstat 3 

Limit number of reports

Run pidstat with interval of 5 seconds, repeat 12 times (=60 seconds), then stop

pidstat 5 12

Disk activity

Show disk activity per process

pidstat -d 3

Single process monitoring

Start Chrome and monitor it, show details every 3 seconds, until Chrome is closed

pidstat 3 -e /opt/google/chrome/chrome

Frequently Asked Questions

What is the pidstat command and its purpose?

Linux systems may use the pidstat command to retrieve system information such as details about CPU, memory, and disk activity by processes.

Which package provides the pidstat command?

The command pidstat is provided by the sysstat package.

Relevant articles using the pidstat command

The following articles include an example on how to use pidstat and might be worth further exploring.

Related and similar commands

Linux has a lot of tools and commands available and sometimes you just need that little other tool. Here is a list of commands that are similar or related to pidstat:

Related and similar commands to pidstat
CommandCategorySummary
basenamefilesStrips directory and file name suffix from a given path
chrtprocessesSets Linux scheduler policy and priority for a process or command
dmidecodehardwareShows hardware information
killprocessesSending signals to processes
lscpumemoryCPU information, virtualization features, CPU vulnerabilities
niceprocessesRuns commands with specified priority
numactlprocessesControls NUMA policy for processes and shared memory
peekfdprocessesTracks a process and show file descriptor activity
pidofprocessesReturns process IDs for a process name
pidwaitprocessesWait for process to stop
pmapprocessesShows memory mapping of process
prtstatprocessesShows process details for selected process like state, CPU and memory usage
pscapcapabilitiesDisplay available capabilities for running processes
pslogloggingShows which log files a process has opened
pstreeprocessesShow active processes and children like a tree
pwdxprocessesShows current working directory of a process
reniceprocessesChanges the priority of running processes
slabtopmemoryShows slab usage of kernel
smemmemoryShow memory usage including swap
straceprocess inspectionInspects running process
unamesystem informationShows basic system information
unitsdata conversionConverts a unit into another one, like from Celcius to Fahrenheit
vmstatmemoryShows virtual memory information, disk IO, CPU activity
watchprocessesMonitors changes in output of specified command

Also 💙 the command-line or terminal? Here is a set of cheat sheets for Linux to get more done from within the shell: