Last active
September 13, 2025 01:17
-
-
Save vadimkantorov/bb99db1ca422ad093292972234440690 to your computer and use it in GitHub Desktop.
Various ps commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| alias cmdline='ps --no-headers -o comm,args -p' | |
| cmdline 1 | |
| # can produce JSON, but without process args | |
| alias notbrokenjson='ps --no-headers -o '\''{"pcpu": %C, "group": "%G", "PPID": %P, "user": "%U", "comm": "%c", "rgroup": "%g", "nice": "%n", "pid": %p, "pgid": %r, "etime": "%t", "ruser": "%u", "time": "%x", "tty": "%y", "vsz": %z}'\'' -p' | |
| notbrokenjson 1 > notbroken.json | |
| # does not remove escape sequences or quotes in args - this will break JSON format for some processes | |
| alias brokenjson='ps --no-headers -o '\''{"pcpu": %C, "group": "%G", "PPID": %P, "user": "%U", "args": "%a", "comm": "%c", "rgroup": "%g", "nice": "%n", "pid": %p, "pgid": %r, "etime": "%t", "ruser": "%u", "time": "%x", "tty": "%y", "vsz": %z}'\'' -p' | |
| brokenjson 1 > brokenjson.json | |
| man ps | |
| #AIX FORMAT DESCRIPTORS | |
| # This ps supports AIX format descriptors, which work somewhat like the formatting codes of printf(1) and printf(3). | |
| # For example, the normal default output can be produced with this: ps -eo "%p %y %x %c". The NORMAL codes are | |
| # described in the next section. | |
| # | |
| # CODE NORMAL HEADER | |
| # %C pcpu %CPU | |
| # %G group GROUP | |
| # %P ppid PPID | |
| # %U user USER | |
| # %a args COMMAND | |
| # %c comm COMMAND | |
| # %g rgroup RGROUP | |
| # %n nice NI | |
| # %p pid PID | |
| # %r pgid PGID | |
| # %t etime ELAPSED | |
| # %u ruser RUSER | |
| # %x time TIME | |
| # %y tty TTY | |
| # %z vsz VSZ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment