http://www.technicalpage.net/search/label/SQL

>> Kill Job or Process


Kill Job or Process :

you can kill a running process/job  by using "kill" command alongwith its  PID :

Let's  run   sleep   1000&  and then kill it :
sleep  1000&    click ENTER , after you click ENTER you get below information :
[1]    9019     where [1]  is the job number and 9019 is the process ID - PID

You can also get the PID using :  ps    or     ps  -e    or    ps  -ef

such as ,
if you click "ps" , you get below informaiton  :
  PID   TTY          TIME CMD
 4443 pts/1      00:00:00 bash
 9019 pts/1      00:00:00 sleep   ---- this the job/process which we need to kill.
 9048 pts/1      00:00:00 ps

" kill "   or  " kill  -9 "

Syntax :
kill  PID   click ENTER
kill  9019    click ENTER
now check the status of the job  sleep   1000&  by  using :  jobs    or     ps    or     ps  -e    or    ps  -ef

if you check the status with the command : "jobs',
it will show  " Terminated  " :
[1]+  Terminated              sleep 1000

if you check with the command "ps",
it will not show the job/process  like below :

  PID TTY          TIME CMD
 4443 pts/1    00:00:00 bash
 9218 pts/1    00:00:00 ps


In many situations , the job will not be terminated/killed  with only "kill" command. In such situation use "-9"  with "kill".

kill  -9   PID    click ENTER  --- this is killing the job/process forcefully.
kill  -9   9019   click ENTER

Now, if you check the status with the command job, it shows  "killed" :
[1]+  Killed                  sleep 1000

if you check with the command "ps",
it will not show the job/process  like  below :

  PID TTY          TIME CMD
 4443 pts/1    00:00:00 bash
 9218 pts/1    00:00:00 ps

No comments:

Post a Comment