O'Reilly logo

Learning Unix for Mac OS X Tiger by Dave Taylor

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Checking on a Process

If a background process seems to be taking forever to run, or if you change your mind and want to stop a process, you can check the status of the process and even cancel it.

ps

When you enter the pscommand, you can see how long a process has been running, the process ID of the background process, and the Terminal from which it was run. The tty program shows the name of the Terminal where the command is running; this is especially helpful when you're logged into multiple machines, as the following code shows:

$ ps
  PID  TT  STAT      TIME COMMAND
  347  p1  S      0:00.17 -bash
  391  p2  S+     0:00.02 -bash
$ tty
/dev/ttyp1

In the output, p1 corresponds to the Terminal window for ttyp1 (which is the current window as the ttycommand shows), and p2 corresponds to the Terminal window for ttyp2. In its basic form, pslists the following:

Process ID (PID)

A unique number assigned by Unix to the process.

Terminal name (TT)

The Unix name for the terminal from which the process was started.

Runtime state (STAT)

The current state of each job. S is sleeping, R is runnable, T is stopped, and I is idle (sleeping for more than 20-30 seconds). Additionally, the state can include + to indicate it's part of the foreground group process, E to indicate the process is exiting, and W to mean it's swapped out.[*]

Runtime (TIME)

The amount of computer time (in minutes and seconds) that the process has used.

COMMAND

The name of the process.

In Unix, each Terminal window has its own name. The previous example shows ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required