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.
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:
psPID TT STAT TIME COMMAND 347 p1 S 0:00.17 -bash 391 p2 S+ 0:00.02 -bash $
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:
A unique number assigned by Unix to the process.
The Unix name for the terminal from which the process was started.
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.[*]
The amount of computer time (in minutes and seconds) that the process has used.
The name of the process.
In Unix, each Terminal window has its own name. The previous example shows ...