Mac OS X Server: ps Command (Process Status)

This article discusses the ps command in Mac OS X Server.
Determining what processes are already running can be an important step in troubleshooting. The command 'ps' (entered on the command line in a Terminial window) with a variety of flags can give information on what is running for the user, the process id, the parent process id, and so forth.

Included in any ps display:
PIDthe process id the number used to identify this process when halting, killing or resuming this process
TTcontrol terminal the session that initiated this process AND when ended, typically ends this process
STATstatefor example (I)dle, (S)leeping, s(T)opped
TIME-cpu time used by the process
COMMAND-which command

Notice that shells (sh, csh, tcsh, bash, for example) show up as processes in most lists.

Following are some common examples of using ps.

ps

Issued alone, ps displays the processes running for that user. So, if you are logged in as mary and run ps, you will see the processes you, mary, are running.

   [mowed:~] george% ps
   PID TT STAT  TIME COMMAND
   1749 p1 I     0:00 -tcsh (tcsh)

ps -a

Displays all processes with terminals. Typically, a user can only view their own processes.

   [mowed:~] george% ps -a
   PID TT STAT  TIME COMMAND
   1749 p1 I     0:00 -tcsh (tcsh)
   1775 p2 I     0:00 login -h 555.555.555.555 -p
   1776 p2 I     0:00 -tcsh (tcsh)
   1789 p2 I     0:00 -csh (csh)
   1822 p2 S     0:00 -tcsh (tcsh)
   1906 p2 R     0:00 ps -a

ps -l

Asks for a long listing, with fields PPID, CP, PRI, NI, ADDR, VSIZE, RSIZE and WCHAN as described below.

   [mowed:~] george% ps -l
          F  UID   PID  PPID CP PRI BASE VSIZE RSIZE WCHAN STAT TT  TIME COMMAND
       4006 32561  1749  1730  0  10   10 2.75M 1.07M     0  I   p1  0:00 -tcsh (tc
       4006 32561  1776  1775  0  10   10 2.75M 1.08M     0  I   p2  0:00 -tcsh (tc
       4006 32561  1822  1789  0  10   10 2.75M 1.05M     0  S   p2  0:00 -tcsh (tc

new items:
F-flags associated with process.
UID-numerical user-id of process owner.
PPIDparent process idgives the id of the process that started this process.
CP-short-term cpu utilization factor (used in scheduling).
PRI-process priority (non-positive when in non-interruptible wait).
VSIZE-virtual size of the process (in bytes).
RSIZE-real memory (resident set) size of the process (in bytes).
WCHAN-event on which process is waiting (an address in the system).

ps -x

Asks even about processes with no terminal. The most common processes with no terminal are daemons or other processes started by the system.

The flags can be combined. For instance, 'ps -alx' is commonly used to view system processes and their parent process ids. 'ps' can be used to display percent of cpu use or memory use as well as other nifty information not covered here. For more information, consult the System Reference Manual by typing the following command at the Terminal prompt:

man ps
Published Date: Feb 20, 2012