pidstat
pidstat helps monitoring processes on their CPU, memory, and disk activity
Typical usage: performance monitoring, system administration, troubleshootingInstallation
When pidstat is not installed by default, it can be added to the system using the relevant software package.
Package information for pidstat
Operating system | Package name | Installation |
---|---|---|
AlmaLinux | sysstat |
|
Arch Linux | sysstat |
|
Debian | sysstat |
|
Fedora | sysstat |
|
Red Hat Enterprise Linux | sysstat |
|
Rocky Linux | sysstat |
|
Ubuntu | sysstat |
|
Your Linux distribution using a different package? Share your feedback.
Usage
Available options
Option | Description |
---|---|
-C NAME | Define task(s) to monitor, may be using regular expression |
-d | Show disk activity |
--dec=0|1|2 | Set number of decimals, with 2 being the default |
-e COMMAND ARGS | Execute a COMMAND (with arguments ARGS) and monitor it with pidstat |
-G NAME | Define process name(s) to monitor, may be using regular expression, can be used with -t |
-H | Include timestamp (seconds since epoch) |
-h | Do not include summary, all output on one line, making it easier to parse by external tools |
--human | Human-readable formats |
-I | Divide CPU usage by total number of processors, for SMP environments |
-l | Include full command and arguments |
-p { pid[,pid2,pid3] | SELF | ALL} | Monitor only one process, multiple processes, pidstat itself, or all |
-R | Show information about realtime priority and scheduling |
-r | Show page faults and memory usage |
-s | Show stack usage |
-T { TASK, CHILD, ALL} | Define what should be included for tasks. |
-t | Include threads with selected tasks, can be used with -G |
-U | Show username instead of UID |
-u | Show CPU usage statistics |
-V | Show version number |
-v | Show information about some kernel tables |
-w | Show 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:
Command | Category | Summary |
---|---|---|
basename | files | Strips directory and file name suffix from a given path |
chrt | processes | Sets Linux scheduler policy and priority for a process or command |
dmidecode | hardware | Shows hardware information |
kill | processes | Sending signals to processes |
lscpu | memory | CPU information, virtualization features, CPU vulnerabilities |
nice | processes | Runs commands with specified priority |
numactl | processes | Controls NUMA policy for processes and shared memory |
peekfd | processes | Tracks a process and show file descriptor activity |
pidof | processes | Returns process IDs for a process name |
pidwait | processes | Wait for process to stop |
pmap | processes | Shows memory mapping of process |
prtstat | processes | Shows process details for selected process like state, CPU and memory usage |
pscap | capabilities | Display available capabilities for running processes |
pslog | logging | Shows which log files a process has opened |
pstree | processes | Show active processes and children like a tree |
pwdx | processes | Shows current working directory of a process |
renice | processes | Changes the priority of running processes |
slabtop | memory | Shows slab usage of kernel |
smem | memory | Show memory usage including swap |
strace | process inspection | Inspects running process |
uname | system information | Shows basic system information |
units | data conversion | Converts a unit into another one, like from Celcius to Fahrenheit |
vmstat | memory | Shows virtual memory information, disk IO, CPU activity |
watch | processes | Monitors 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: