% ps -ef
UID PID PPID C STIME TTY TIME COMMAND
root 0 0 0 Dec 31 ? 0:56 swapper
root 1 0 0 Mar 9 ? 0:02 init
root 2 0 0 Mar 9 ? 4:15 vhand
Most of the process are system processes or daemons. They are processes
that act without user request. To search for a particular string in the process
list I could pipe the output of ps to the grep command.
% ps -ef | grep scot
UID PID PPID C STIME TTY TIME COMMAND
scot 4948 4944 0 Mar 17 ttyp2 1:59 emacs chapter2.html
scot 4934 4928 0 Mar 17 ? 2:08 vuewm
scot 4941 4928 0 Mar 17 ? 0:08 hpterm
scot 4944 4940 0 Mar 17 ttyp2 0:04 tcsh
scot 4942 4928 0 Mar 17 ? 0:00 xload -name vueload -nolabel
This will give a listing of all proceses that the user scot is running.
% sleep 400 & [2] 8416 %The sleep command is used as a time delay. It does nothing more than wait until its time runs out. After you ran the process a number appeared on the screen. This number is the process identification number(PID). We will use that number in the next section to kill the process.
If you have created a background process and you log off, your process will be killed since it is associated with your shell. The nohup (no hangup) command allows you to keep processes running after you have logged off. The nohup command, is usefull if you have a process that needs to run all night or a few weeks.
% nohup sleep 400 &Now when we exit from the shell the sleep process will still be running.
All user processes have the same priority. Each is given the the same treatment by the CPU. However, if you leave a process running with the nohup command you should use the nice command to reduce its priority.
% nohup nice sleep 400 &This will reduce the priority of sleep by a factor of ten.
% ps -ef | grep sleep
scot 8419 4944 3 20:17:42 ttyp2 0:00 grep sleep
scot 8416 4944 0 20:17:32 ttyp2 0:00 sleep 400
% kill 8416
[2] Terminated sleep 400
%
A process is stopped when a kill signal is sent to it. Signal number range from 1 to 31.
When you kill a process the default signal is 15. Some processes will ignore this signal.
A sure way to kill these processes is with signal number 9. One process that will not die with kill signal 15 is the shell. Lets start a C-shell process and then try to kill it with signal 15. We will then kill the process with signal 9.
% csh % ps PID TTY TIME COMMAND 4944 ttyp2 0:04 tcsh 8429 ttyp2 0:00 csh 8430 ttyp2 0:00 ps % kill 8429 % ps PID TTY TIME COMMAND 4944 ttyp2 0:04 tcsh 8429 ttyp2 0:00 csh 8431 ttyp2 0:00 ps % kill -9 8429 Killed %