how to kill ?
i have got 10 process numbers
say, 123 456 678 907 ..... How do i kill all of them in one go >? kill - 15 123 456 678 907 ..blah blah ...does it work ? |
i have seen -15 is an additional parameter to be used in my manual given to me.
i dont know what it does. |
Yes it should work with the GNU version of kill. I think some non-gnu implementations on other unix-like OSes may only accept one PID at a time.
The one problem with your command: the "- 15" shouldn't have a space in it. What kill does is send a signal to the specified processes. Signals can be specified numerically or by their name. If you don't tell kill which signal to send, it sends one called SIGTERM (number 15). You can get a list of signal names/numbers by using the command: Code:
kill -l Background: for many signals the default action of a program is to terminate. Programmers can change this behaviour for most signals - all except number 9 - SIGKILL. SIGKILL will always terminate a program. Thus you often see people going something like this: Code:
$ ps |
Quote:
yahoooo.....thank you. so you approve that the command works ...right ? but i dont understand what that 15 does ? please explain it. and how does system will understand that 15 is not a process id ? is it really that no process can have id 15 , 9 etc ? Code:
kill -l Background: for many signals the default action of a program is to terminate. Programmers can change this behaviour for most signals - all except number 9 - SIGKILL. SIGKILL will always terminate a program. Thus you often see people going something like this: Code:
$ ps |
Sorry, I was a little unclear.
If the first parameter to kill starts with - followed by a number (with no spaces in between), that number is interpretted as the signal number to send to the process IDs (the other numbers on the command line). If the first parameter to kill doesn't start with a - the default signal number is used (15). you can see the names associated with the signal numbers by using the "kill -l" (lower case L) command. Here's a few which are commonly used from the command line:
Incidentally, you don't have to use the signal number to specify a signal. You can also do this: Code:
kill -KILL 12345 |
Check out the following commands to better understand kill:
man kill info kill You will find many answers this way. Using man and info before any command you have a question about will pull up its documentation. |
type ps - e | less
now you can navigate all the list of running task number followed by the name. then kill [number] e.g. kill 1001; |
See also killall
|
Quote:
As said, kill distinguishes the process IDs from the signal number by the "-" in front. That's why you shouldn't put a space between "-" and the signal number as well. If you're worried about typos (ie mistakingly putting in the space), then you should stick with the names of the signals. |
Hi there
I've read the above but still can't see how to use this command. Yast has locked up on my laptop (does it regularly!) How do I kill it?? I use the kill command, but with what? you seem to say that processes have numbers.. how do I find this out for Yast? Thanks |
OK, I don't have SuSE, so I can't tell you exactly how to kill off YaST because it only runs with SuSE. I can provide an example which is very similar though, and you should be able to apply this process to your problem.
Killing Synaptic Package Manager First thing to note - killing off synaptic if it's half way through installing something may leave your package database in a bad way, and you'll have to fix this somehow. This is just an example! OK, lets assume synaptic is running, but has locked up. Here's how to kill it using the kill command. Firstly, synaptic runs with root permissions. This means regular users can't send signals to it - only root can send signals to a process running as root. Because of this, we need to start a terminal, and switch to the root user. There several ways to do this. On systems which allow it, the easiest way is to use the command Code:
su - root For systems which disable the root user, such as ubuntu, you can still get a root shell by using this command as a user who is allowed to use sudo: Code:
sudo bash OK, so now you should have a terminal running with a root shell. The next step is to find out the process ID (PID) of the process which we want to kill. We know the name of the program - in this case synaptic. There are lots of ways to find the process ID of the process, but we're going to use the time-old ps and grep method. Here's the command: Code:
ps aux |grep -i synaptic Here's the output I get: Code:
root 6950 1.1 4.9 50496 25504 pts/1 S 12:32 0:02 synaptic So now we know the process ID to kill, lets kill it. First we'll let kill send the default signal, which is called SIGTERM. This signal will "request" that the program terminates. Maybe the program will ignore this. Lets see. Notice that since we're send the default signal, we don't need to tell kill which signal - we don't provide the -TERM or -15 option. Code:
kill 6950 Code:
ps aux |grep -i synaptic If it had not died, we could have got serious by sending the KILL signal. This doesn't just ask a process to terminate, it tells it. There's no argument with the kill signal. Here's how I would have done it: Code:
kill -KILL 6950 Code:
kill -9 6950 Now the caveats.
Hope that wasn't too long and boring. |
Too long and boring??? No way!!
That is such a great answer - thank you so much for talking me through it all. :) I can now play around and see what happens. Thank you for taking the time to explain. |
Good, glad to help.
There are several other programs which can list and send signals to processes, but kill from a terminal is a good approach especially if you need to switch user before using it. If you use the gnome desktop environment, there is a program called "gnome-system-monitor" which can list processes and you can use it to send TERM and KILL signals etc. In ubuntu, this is available from the administratioon menu, called "System Monitor". "KDE system guard" has similar facilities for KDE users. On kubuntu, pressing control-escape launches KDE system guard. Both of these programs have nice GUI interfaces, so if you prefer that sort of thing try them. The command line discussed here is more consistently available across different unix-like OSes - I can use ps, kill and grep from the terminal on Solaris, HPUX, BSD, Linux, etc (although sometimes the exact usage differs a little between these OSes). The other advantage is for administering remote machines for which you can't use a GUI for some reason (many servers don't run X, or maybe the connection isn't fast enough to conveniently use a remote X session). |
All times are GMT -5. The time now is 09:07 AM. |