Skip to content
Latchkey

ps: Usage, Options & Common CI Errors

ps takes a snapshot of the processes currently running.

ps is how you find a runaway or stuck process - the background server that never died, the job eating all CPU. In CI it pairs with kill to clean up before a step hangs.

What it does

ps reports a snapshot of current processes with their PIDs, owners, CPU/memory use, and command lines. Its two flag styles - BSD (aux) and UNIX (-ef) - both list all processes.

Common usage

Terminal
ps aux                         # all processes, BSD style
ps -ef                         # all processes, UNIX style
ps aux | grep '[n]ode'         # find node procs (bracket avoids self)
ps -o pid,ppid,%cpu,%mem,cmd --sort=-%cpu | head
ps -p $PID -o stat=            # state of one PID

Options

ItemWhat it does
auxBSD: all users, with details
-efUNIX: every process, full format
-o <cols>Choose output columns
--sort=-%cpuSort (descending) by a column
-p <pid>Limit to a PID

Common errors in CI

On minimal images (Alpine/distroless) ps is BusyBox or absent, so ps aux flags may differ or fail - check /proc or install procps. grep-ing your own grep line is a classic noise source; use the [n]ode bracket trick. To act on results, capture the PID (pgrep -f pattern is cleaner) and kill it. Remember ps is a snapshot, not live - use top for continuous view.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →