Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I want to kill some of Apache server process in Linux.
Please help me in this.
if you have pid of the processes that want to kill then use kill command.
kill pid1 [pid2 pid3 ...]
And if this doesn't kill the processes you can add -9 flag to kill command to forcefully kill the processes like
kill -9 pid1 [pid2 pid3 ...]
To get the pid of the process you can use ps command as
ps ax | grep apache
first column of output is the pid of the process.
Try the following:
killall apache2
if you want to kill all apache processes.
ps aux | grep apache2
will show the apache servers with their PID. Then you can kill selectively:
kill -9 pid1 pid5
Note the Linux command killall. You can kill processes by name and thus do something a little more coarse-grained than using the pid. You can use names or regular expressions (with the -r option) to specifiy your victims.
Use a normal SIGTERM (default) to begin with. This will let the processes catch the signal, and if they're well-behaved they'll clear up/close resources properly and then exit. Only if the processes don't respond should you use the SIGKILL (-9) signal.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
I have a a.sh script that executes a infinite loop with a list of commands in background in a Debian machine and I would like to use another script b.sh to end with a.sh. As far as I know pkill -f a.sh is one way of doing it, but I want to know if there is another way of doing it
man -k kill shows many commands to kill processes. Watch out (1) (general commands) and (8) (admin commands). At my system I get (manually filtered):
killproc (8) - Send signals to processes by full path name
docker-container-kill (1) - Kill one or more running containers
docker-kill (1) - Kill one or more running containers
kill (1) - terminate a process
killall (1) - kill processes by name
killall5 (8) - send a signal to all processes.
pkill (1) - look up or signal processes based on name and other attributes
skill (1) - send a signal or report process status
If you run a.sh from b.sh you can get the process id of a.sh
b.sh
a.sh & # Execute a.sh in the background
APID=$! # $APID is now the pid of a.sh
#do some stuff or wait
kill -SIGTERM $APID # Give the process a chance to shut down
kill -SIGKILL $APID # Certain kill
This way you can kill the particular instance of a.sh if you have multiple concurrent
instances.
This question already has answers here:
Kill all processes for a given user
(5 answers)
Closed 3 years ago.
I have a bunch of processes on my school's server that have been running for about a week without it being terminated. I found out that I could use "kill -9 [PID]" for each of the PIDs, but it took me awhile to individually kill each of them.
If, for instance, I have hundreds of processes I want to forcefully kill, is there a way to kill them all instantly?
You don't linux has number of commands, use the following with caution, killall or you could try pkill -U UID or pkill -U username
Note when using pkill, it will kill all processes including your tty terminal session if you are using SSH, you will be kicked out!
You can kill process by grep your applicationName. For example
ps aux |grep kpark06 | awk '{print $2}' | xargs sudo kill -9
man kill:
kill [options] [...]
<pid> can be a list. You can put a giant space-separated list of processes after kill, like kill 123 543.
A PID of -1 is special; it indicates all processes except the kill process itself
and init
So, kill -9 -1 will get everything, but that could easily be more than you expect. Having no idea what else is running there, I would only kill all the processes if prepared to restart the server.
If these processes have something in common, you may want killall, which can filter the processes to kill by age, user, and name/context regular expression, as well as asking for confirmation.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I am having trouble with exiting past nodemon instance.
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 98355 user 14u IPv6 0x51b8b9857a4e56a3 0t0 TCP *:redwood-broker (LISTEN)
It has taken my 3000 port so I am trying to exit it. I searched it by using lsof -wni tcp:3000
I could see that PID is 98335, so tried kill 98335, kill -9 98335, sudo kill 98335, sudo kill -9 98335 and so on but no luck, it's just saying
kill: kill 98335 failed: no such process
But if I save something, nodemon watching job is printing out to console, which means that process is still alive.
Please help me.
https://github.com/remy/nodemon/issues/1386
To work around the issue, find the proces running on the port number and kill it:
kill -9 $(lsof -t -i:3000)
OR
Install 1.17.5 npm install nodemon#1.17.5 --save-dev --save-exact.
you can use
ps -ef | grep node
to find the process id
and then
sudo kill -9 <PID>
PID is the process ID. Try the following command in terminal to list and search for process using a regex:-
ps gx | grep 'Symantec'
The above example is to list all the 'Symantec' related processes. Replace 'Symantec' with your own phrase. Next use variations of 'kill' command. You can either use:-
kill pid
Replace 'pid' with actual process id. Or use,
killall
as suggested before. To reiterate another useful suggestion, use
man kill
to see the manual for 'kill' command and also scroll down and see related commands which is mentioned under.
to kill all running node processes with -9 option
sudo pkill -f node -9
sudo kill -9 PID
This will forcefully kill your process
you kill wrong PID its 98355 not 98335
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I would like to kill a particular process (it is a program which name is test.exe) in Linux. To do that I can type:
ps aux | grep test.exe
And then:
kill -9 process_id_of_test_exe
As You can see I need to type commands several times (not immediately). The question is how to do that in one command. Take the process_id of test.exe and give to kill. I think that I need to write a script in such case. Thanks.
Use this command to get PID
pidof test.exe
1044
Then to kill it:
kill 1044
And then join them:
kill $(pidof test.exe)
You can also use your command:
kill -9 $(ps aux | grep [t]est.exe)
The [t] prevents grep from grepping itself.
Try:
killall test.exe
See man killall for more details!
You can combine kill -9 with pgrep like follows:
kill -9 `pgrep test.exe`
For killing all processess with keyword test.exe, try
pkill -9 -f test.exe
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
server01:/# ps -ax | grep java
Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html
7342 pts/3 Z 0:00 [java] <defunct>
7404 pts/3 S+ 0:00 grep java
server01:/# kill 7342
server01:/# ps -ax | grep java
Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html
7342 pts/3 Z 0:00 [java] <defunct>
7406 pts/3 S+ 0:00 grep java
server01:/#
In the above I am using ps command to know the pid of the java process which is 7342 in the above case.
Then I killed that process using kill command.
But that is not killed because again ps command shows java process with pid 7342.
Should I use some else command to kill the process and Why kill is not able to kill the process
Thanx
try
ps aux
then
kill -1 PID_NUMBER
to ask program to close itself, if it dosn´t answer you can force it to close
kill -9 PID_NUMBER
remember that using -9 to force program will finalize without asking and not saving anything
check: man kill
for more details
Linux supports the BSD style switches to the ps command (without the leading - ... dash/hyphen). If one supplies the hypen then the GNU coreutils version of ps (the one which is standard on mainstream Linux distributions) will attempt to interpret the switches as SysV compatible. This is the source of your error.
I'd recommend using the BSD form of the switches and look up the -o option to specify an output format consisting ONLY of the PID of the matching processes.
Also you're attempting to kill a zombie. As you've discovered that's a futile effort. A zombie is a placeholder in the process able for a process which is already dead. It remains in the process table until its parent process "reaps" its exit code. If the parent never does a wait() system call then the entry will stay there until after the parent is killed, at which point the zombie (and any other orphaned processes) will be inherited by the init process. The normal init under Linux (or any other form of UNIX) periodically reaps all dead processes (zombies).
Conceptually every process that exits on a UNIX/Linux system spends a small amount of time as a "zombie" ... that is there should always be a period of time between the process' termination and the time when some other process reads its exit value (even if only to discard it, as init does).
This question really should go on ServerFault
kill -9 can be used as a last resort to ensure the process dies.....
The process is listed as defunct. It's job is done and it's kept around because the parent process is still there. However, if the parent crashed or was killed by kill -9, there is no parent process, so the defunct process will kept around until reboot.
Defunct (or zombie) processes use only minimal resources, so you can keep them.
Solution: Either kill the parent or use kill -9 <pid>.
kill -9 $(pgrep -f keyword).
Kill pid(s) searched by 'KEYWORD';
kill $(pgrep [search pattern])
See if that works better. You have to be either root or the process owner to kill a process.
The java process has become a zombie process. You should try sending the SIGCHLD signal to the parent process via kill to tell the parent process to reap the zombie child process. Failing that, as mentioned by #Martin, you could kill the parent or kill -9 the zombie process.