This site will look much better in a browser that supports web standards, but it is accessible to any browser or Internet device.

ps command »


Using the ps Command

The ps command allows you to list what processes are being executed by the machine on which the command was entered.

To list all your processes on godzilla, octavian, and other Solaris 2.X machines, use the command ps -u loginname.

	peteranteater@octavian% ps -u peteranteater
	   PID TTY        TIME COMD
	  5074 pts/0      0:21 tcsh-6.0
	 20272 pts/0      0:00 ps
	  5073 ?          0:18 xterm

          

To list all your processes on clyde or other SunOS 4.1.X machines, use the command ps -gx.

	peteranteater% ps -gx
	  PID TT STAT  TIME COMMAND
	 8793 p1 S     0:07 -tcsh (tcsh)
	11373 p1 R     0:00 ps -gx
	 9538 ?? S     0:03 xbiff

          


ps Output

PID
Process ID, each process has a PID associated with it.
TT, TTY
Terminal shell from which the process is being run.
STAT
State of process, S=sleeping R=running W=waiting I=idle.
TIME
CPU time that the process has been running, not real time.
COMMAND, COMD
Command name being run.

See man ps for more information.


Run Away Processes

Sometimes programs do not exit properly and continue to run, taking up system resources after you logout. This will result in the system being slow and make it difficult for people to get their work done.

If you list your processes and something is running that you are not aware of, then you have a run away process. To get rid of these processes you must ``kill'' them.

There are different levels to the kill command. First find the lost process PID using ps and type kill PID. This mode of kill will ask the process to exit nicely. Check your processes again after running the kill command to make sure that it was successful. If the process is still running then you can use higher "levels" of kill to get rid of the process. To do this, type kill -KILL PID. If the process is still running, use kill with the -9 flag. See man kill for more information.

If you have a process which takes either more than 1 hour to complete or appears that it could take more than 10 CPU minutes, it should be run at nice +19 (see the section on Nicing Processes).

Please avoid running unnecessary processes, such as xdaliclock, xearth, or xeyes, which waste cpu time and network bandwidth.

Programs that are often known for not exiting cleanly, and often need to be killed:

Netscape
scl
Netperf
IDE tools (ade, stp, dfe)


How to nice a process

If you know before you start it that the job needs to be niced, you can use the command: nice -priority command.

If you need to nice a process that is already running (e.g. you started it, then realized it was going to take too much CPU time), get the PID of the process (using ps) and use the command: renice priority -p PID.

See man nice for more information.