Processes
prtstat
Display process statistics from the proc filesystem.
Additional Notes
prtstat displays detailed statistics about a running process by reading information from the /proc filesystem. It shows the process name, PID, parent PID, state, user and system CPU time, priority, nice value, memory usage, I/O counters, signal masks, and scheduling information.
System administrators and developers use prtstat to get a comprehensive snapshot of a process's state and resource usage. It provides more detail than ps -p PID in a single consolidated view, though much of the same information is available from /proc/PID/stat and /proc/PID/status.
Syntax
prtstat [options] [pid...]
Parameters
pid: One or more process IDs to examine.
Common Options
-r,--raw: Output in raw format (machine-parseable).-n,--nocolumns: Suppress column headers.-h,--help: Show help and exit.-v,--version: Show version information.
Examples
prtstat 1234
Display statistics for PID 1234.
prtstat $$
Show statistics for the current shell process.
prtstat 1
Show statistics for the init or systemd process.
prtstat -r 1234 > stats.txt
Save raw process statistics to a file.
prtstat $(pidof nginx)
Show statistics for all nginx processes.
prtstat -n 1234
Show statistics without column headers.
Practical Notes
prtstatreads from/proc/PID/stat. If the process terminates beforeprtstatreads it, an error is returned.- Most of the same information is available from
ps -p PID -o pid,ppid,stat,etime,time,%cpu,%mem,rss,vszor by reading/proc/PID/statusdirectly. prtstatis part of thepsmiscpackage on some distributions. Install withsudo apt install psmisc.- For continuous monitoring, use
top,htop, orpidstatfrom thesysstatpackage. - The raw output (
-r) is useful for parsing in scripts, though directly reading/proc/PID/statmay be simpler.