Using the
ThepsCommandpscommand 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 xtermTo 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
psOutputSee
- 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.
man psfor 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
killcommand. First find the lost process PID usingpsand typekill PID. This mode ofkillwill ask the process to exit nicely. Check your processes again after running thekillcommand to make sure that it was successful. If the process is still running then you can use higher "levels" ofkillto get rid of the process. To do this, typekill -KILL PID. If the process is still running, usekillwith the -9 flag. Seeman killfor 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, orxeyes, 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
nicea processIf 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 nicefor more information.