PIDSTAT(1)
๐ pidstat(1) ๐
Linux User's Manual โจ pidstat is the manual name, bestie ๐ฆ
๐ธ NAME ๐ธ
pidstat - Report statistics for Linux tasks. ๐
๐ SYNOPSIS ๐
pidstat [ -d ] [ -H ] [ -h ] [ -I ] [ -l ] [ -R ] [ -r ] [ -s ] [ -t ] [ -U [ username ] ] [ -u ] [ -V ] [ -v ] [ -w ] [ -C comm ] [ -G process_name ] [ --dec={ 0 | 1 | 2 } ] [ --human ] [ -o JSON ] [ -p { pid[,...] | SELF | ALL } ] [ -T { TASK | CHILD | ALL } ] [ interval [ count ] ] [ -e program args ]
๐ท DESCRIPTION ๐ท
okay so pidstat is the command you use to keep an eye on the individual tasks the Linux kernel is currently juggling ๐. It spits its stats out to standard output for every task you pick with -p, or for literally every task on the system if you use -p ALL ๐
. If you don't select any tasks at all, that's the same as -p ALL, but only the active tasks (the ones with non-zero stats) show up in the report. no cap, very helpful ๐ซถ
It can also keep tabs on the child processes of whatever tasks you've selected. Check out -T below for the tea on that one โ.
The interval parameter is how many seconds go by between each report โฐ. If you give it a value of 0 (or you don't give any parameters at all), the stats are reported for the time since the system booted ๐ฅน. The count parameter only works alongside interval, and only if interval isn't zero. It decides how many reports get generated, spaced interval seconds apart โจ. If you give interval but skip count, pidstat just keeps reporting nonstop, iykyk ๐.
You can pick out specific task activities with flags ๐ฉ. And if you don't use any flags? You only get CPU activity, periodt ๐.
๐ OPTIONS ๐
-C commโ Only show tasks whose command name includes the string comm. Yes, this string can be a regular expression, we love a power move ๐ฅ.-dโ Report I/O statistics. This only works on kernels 2.6.20 and later, so no old-school vibes ๐ฐ๏ธ. Here's what you'll see:UIDโ The real user ID number of the task being monitored ๐.USERโ The name of the real user who owns the task being monitored ๐ง.PIDโ The ID number of the task being monitored ๐ข.kB_rd/sโ How many kibibytes the task has made get read from disk per second ๐.kB_wr/sโ How many kibibytes the task has caused, or is about to cause, to get written to disk per second โ๏ธ.kB_ccwr/sโ How many kibibytes that were headed for disk got cancelled by the task. This can happen when the task truncates some dirty pagecache. In that case, some I/O that another task got credited for won't actually happen ๐.iodelayโ The block I/O delay of the task being monitored, measured in clock ticks โฑ๏ธ. This includes the delays spent waiting for sync block I/O to finish, and for swapin block I/O to finish too ๐ข.Commandโ The command name of the task ๐ฌ.
--dec={ 0 | 1 | 2 }โ Pick how many decimal places you want, anywhere from 0 to 2. The default is 2 ๐ฏ.-e program argsโ Run program with the given args and monitor it withpidstat.pidstatstops once program finishes ๐. You have to give the interval parameter a non-zero value for this one ๐ซก.-G process_nameโ Only show processes whose command name includes the string process_name. Regular expressions are welcome here too ๐. If you use-ttogether with-G, the threads that belong to that process get shown as well, even if their command name doesn't include process_name ๐งต.-Hโ Show the timestamp in seconds since the epoch ๐ฐ๏ธ.-hโ Show all activities horizontally on one single line, and skip the average statistics at the end of the report ๐. This is made so other programs can parse it more easily ๐ค.--humanโ Print sizes in a human readable format, like1.0kor1.2M๐ง. The units shown with this option replace any other default units attached to the metrics, like kibibytes or sectors ๐ช.-Iโ On an SMP system, this tellspidstatto divide the tasks' CPU usage (the stuff-ushows) by the total number of processors ๐งฎ.-lโ Show the process command name and all of its arguments ๐.-o JSONโ Show the stats in JSON (JavaScript Object Notation) format ๐งพ. The field order in JSON output is undefined, and new fields might get added in the future, so don't lock your code to one exact order ๐.-p { pid[,...] | SELF | ALL }โ Pick the tasks (processes) you want stats for ๐ฏ. pid is the process ID number. TheSELFkeyword means "report on thepidstatprocess itself" ๐ช, while theALLkeyword means "report on every single task the system manages" ๐.-Rโ Report realtime priority and scheduling policy info ๐ฆ. Here's the lineup:UIDโ The real user ID number of the task being monitored ๐.USERโ The name of the real user who owns the task being monitored ๐ง.PIDโ The ID number of the task being monitored ๐ข.prioโ The realtime priority of the task being monitored ๐ฅ.policyโ The scheduling policy of the task being monitored ๐.Commandโ The command name of the task ๐ฌ.
-rโ Report page faults and memory utilization ๐ง .
When you're looking at individual tasks, you can see:
UIDโ The real user ID number of the task being monitored ๐.USERโ The name of the real user who owns the task being monitored ๐ง.PIDโ The ID number of the task being monitored ๐ข.minflt/sโ The total number of minor faults the task made per second. These are the ones that didn't need a memory page loaded from disk ๐.majflt/sโ The total number of major faults the task made per second. These are the ones that did need a memory page loaded from disk ๐ฌ.VSZโ Virtual Size: the virtual memory usage of the entire task, in kibibytes ๐.RSSโ Resident Set Size: the non-swapped physical memory the task is using, in kibibytes ๐พ.%MEMโ The task's currently used share of the available physical memory ๐ฅง.Commandโ The command name of the task ๐ฌ.
When you're looking at global stats for tasks and all their children, you can see:
UIDโ The real user ID number of the task being monitored, along with its children ๐.USERโ The name of the real user who owns the task being monitored, along with its children ๐ง.PIDโ The ID number of the task being monitored, along with its children ๐ข.minflt-nrโ The total number of minor faults made by the task and all of its children, collected during the interval ๐ซง.majflt-nrโ The total number of major faults made by the task and all of its children, collected during the interval ๐ซ .Commandโ The command name of the task being monitored, along with its children ๐ฌ.
-sโ Report stack utilization ๐ฅ. The values you can see are:UIDโ The real user ID number of the task being monitored ๐.USERโ The name of the real user who owns the task being monitored ๐ง.PIDโ The ID number of the task being monitored ๐ข.StkSizeโ The amount of memory in kibibytes reserved for the task as stack, but not necessarily used ๐ฆ.StkRefโ The amount of memory in kibibytes actually used as stack and referenced by the task ๐.Commandโ The command name of the task ๐ฌ.
-T { TASK | CHILD | ALL }โ This decides whatpidstatmonitors ๐. TheTASKkeyword reports stats for individual tasks, and that's the default ๐ . TheCHILDkeyword reports stats globally for the selected tasks and all their children ๐จโ๐ฉโ๐ง. TheALLkeyword does both: individual tasks and the global stats for the selected tasks and their children ๐.
Note: Global stats for tasks and all their children aren't available for every pidstat option ๐
โโ๏ธ. Also, these stats aren't necessarily relevant to the current time interval. A child process's stats only get collected when it finishes or gets killed โฐ๏ธ.
-tโ Also show stats for the threads linked to the selected tasks ๐งต.
This option adds these values to the reports:
TGIDโ The ID number of the thread group leader ๐.TIDโ The ID number of the thread being monitored ๐ชก.
-U [ username ]โ Show the real user name of the tasks being monitored instead of the UID ๐งโ๐คโ๐ง. If you give username, only the tasks that belong to that user will show up ๐.-uโ Report CPU utilization ๐ฅ.
When you're looking at individual tasks, you'll see:
UIDโ The real user ID number of the task being monitored ๐.USERโ The name of the real user who owns the task being monitored ๐ง.PIDโ The ID number of the task being monitored ๐ข.%usrโ The percentage of CPU the task used while running at the user level (application), with or without nice priority ๐ง. Heads up: this does NOT include time spent running a virtual processor ๐ .%systemโ The percentage of CPU the task used while running at the system level (kernel) ๐ ๏ธ.%guestโ The percentage of CPU the task spent in a virtual machine, running a virtual processor ๐ฅ๏ธ.%waitโ The percentage of CPU the task spent waiting to run โณ.%CPUโ The total percentage of CPU time the task used ๐ฏ. On an SMP system, the task's CPU usage gets divided by the total number of CPUs if you've put-Ion the command line ๐งฎ.
CPUโ the processor number the task is hanging out on ๐งCommandโ the command name of the task โจ
When you're looking at global stats for a task and all of its children, you might see these ๐
UIDโ the real user ID of the task being watched, along with its children ๐USERโ the name of the real user who owns that task and its children ๐ซถPIDโ the ID number of the task being watched, children included ๐ขusr-msโ the total milliseconds the task and its children spent running at the user level (apps ๐ ), with or without nice priority, during the interval. Heads up: this does NOT count time spent running a virtual processor ๐ โโ๏ธsystem-msโ the total milliseconds the task and its children spent at the system level (kernel ๐ง), during the intervalguest-msโ the total milliseconds the task and its children spent inside a virtual machine, running a virtual processor ๐Commandโ the command name of the task, plus its children ๐
-Vโ prints the version number, then exits. Simple, iconic, done ๐-vโ reports values from some kernel tables ๐ฆ You'll see these fields:UIDโ the real user ID of the task being monitoredUSERโ the name of the real user who owns the task being monitoredPIDโ the ID number of the task being monitoredthreadsโ how many threads belong to the current task ๐งตfd-nrโ how many file descriptors belong to the current task ๐Commandโ the command name of the task
-wโ reports task switching activity ๐ Heads up: this one only works on kernels 2.6.23 and later โ ๏ธ You'll see:UIDโ the real user ID of the task being monitoredUSERโ the name of the real user who owns the task being monitoredPIDโ the ID number of the task being monitoredcswch/sโ how many voluntary context switches the task made per second. That's when a task blocks itself because it needs a resource that isn't available right now ๐ดnvcswch/sโ how many non-voluntary context switches the task made per second. That's the drama one: a task runs for its whole time slice and then gets forced to give up the processor ๐คCommandโ the command name of the task
โจ ENVIRONMENT โจ
okay so pidstat pays attention to these environment variables, so you can customise your vibe ๐
S_COLORSโ by default, stats show up in color when the output is going to a terminal ๐ Use this one to change things. The possible values arenever,alwaysorauto(andautois the same as the default, so you're already set ๐ซถ). Also, don't read into the colors! Red or yellow doesn't mean something is wrong, it just marks different ranges of values ๐S_COLORS_SGRโ this one sets the colors and other text attributes used to display stats in the terminal ๐จ Its value is a colon-separated list of capabilities, and the default isI=32;22:N=34;1:W=35;1:X=31;1:Z=34;22. The capabilities you can use are:I=โ the SGR (Select Graphic Rendition) substring for item values, like PID, UID or CPU number ๐ขN=โ the SGR substring for non-zero statistics values and for task names ๐W=(orM=) โ the SGR substring for percentage values in the range from 75% to 90% (or in the range 10% to 25%, depending on what the metric means) โ ๏ธX=(orH=) โ the SGR substring for percentage values greater than or equal to 90% (or lower than or equal to 10%, depending on the metric) ๐จZ=โ the SGR substring for zero values and for thread names ๐ค
S_TIME_FORMATโ if this variable exists and its value isISO, the current locale gets ignored when the date is printed in the report header ๐๏ธpidstatwill use the ISO 8601 format (YYYY-MM-DD) instead, and the timestamp will be ISO 8601 compliant too โจ
โจ EXAMPLES โจ
okay now for the fun part, bestie ๐ here are some combos you can copy:
pidstat 2 5
Shows five reports of CPU stats for every active task on the system, at two second intervals ๐
pidstat -r -p 1643 2 5
Shows five reports of page faults and memory stats for PID 1643, at two second intervals ๐ง
pidstat -C "fox|bird" -r -p ALL
Shows global page faults and memory stats for every process whose command name includes the string "fox" or "bird" ๐ฆ๐ฆ
pidstat -T CHILD -r 2 5
Shows five reports of page faults stats at two second intervals for the child processes of all tasks on the system ๐ถ Only child processes with non-zero stats get displayed, so no clutter ๐ซถ
โจ BUGS โจ
โ ๏ธ the/procfilesystem must be mounted forpidstatto work at all. No/proc, no vibes ๐
Even though pidstat shows units that look like kilobytes (kB), megabytes (MB)..., it's actually using kibibytes (kiB), mebibytes (MiB)... ๐ค A kibibyte is 1024 bytes, and a mebibyte is 1024 kibibytes. Lowkey a plot twist ๐
โจ FILES โจ
/proc is where the various files with system statistics live ๐๐ง
โจ AUTHOR โจ
Sebastien Godard (sysstat <at> orange.fr) ๐ the legend behind it ๐ซถ
โจ SEE ALSO โจ
sar(1), top(1), ps(1), mpstat(1), iostat(1), vmstat(8) โ go check these out, they're giving ๐ฆ
For more, peep https://github.com/sysstat/sysstat and https://sysstat.github.io/ ๐ธ
bestie, that's the whole thing ๐ pidstat, sysstat-approved, from the Linux crew, last updated JANUARY 2025, and you are officially a PIDSTAT(1) expert now ๐โจ๐
๐ฆ where this page comes from
- alpine 3.24: sysstat-doc 12.7.8-r0 ยท GPL-2.0-or-later
- arch rolling: sysstat 12.8.0-1 ยท GPL-2.0-only
- fedora 43: sysstat 12.7.8-1.fc43 ยท GPL-2.0-or-later
- fedora 44: sysstat 12.7.9-2.fc44 ยท GPL-2.0-or-later
- nixos 26.05: sysstat 12.7.7
- nixpkgs unstable: sysstat 12.8.0
- ubuntu questing: sysstat 12.7.7-0ubuntu1 ยท GPL-2.0-or-later
- ubuntu resolute: sysstat 12.7.7-0ubuntu2 ยท GPL-2.0-or-later
- ubuntu stonking: sysstat 12.7.7-0ubuntu2 ยท GPL-2.0-or-later
- (C) 2007-2025 Sebastien Godard (sysstat <at> orange.fr)
- ๐ girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms