How to kill nodemon process on mac? [closed] - node.js

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

Related

How to kill a process in bash through terminal [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
This might be a very basic question but I couldn't find it anywhere on the internet.
Lets assume I have a file named test with this code
echo hello
sleep 10
echo hello
sleep 10
echo hello
sleep 10
How would I go about killing that program through another terminal in my server?
I am assuming the file is test.sh
You can do:
ps -x | grep ./test.sh
This will show the processes:
11164 pts/1 S+ 0:00 /usr/bin/bash ./test.sh
and a second process that will be a grep process, you won't be able to kill the process that has the word grep in it because that process completes right away
now you can kill the process using the PID:
kill 11164
Your script filename is test.
So, in another terminal, you can execute ps aux | grep test.
Then you can get the PID of test, which is located at the second column.
Then, execute kill -9 <PID>.
Ctrl c
By Pressing this, you can kill that program from your terminal.
And you can kill this program from your main terminal where you exicute this in first place.

Linux "kill -9 <PID>" for all processes? [duplicate]

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.

How to kill more than one process in linux? [closed]

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.

Killing a process in linux [closed]

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.

Freeing up a TCP/IP port? [closed]

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 12 months ago.
The community reviewed whether to reopen this question 12 months ago and left it closed:
Original close reason(s) were not resolved
Improve this question
netstat -tulnap
shows me what ports are in use. How to free up a port in Linux?
As the others have said, you'll have to kill all processes that are listening on that port. The easiest way to do that would be to use the fuser(1) command. For example, to see all of the processes listening for HTTP requests on port 80 (run as root or use sudo):
# fuser 80/tcp
If you want to kill them, then just add the -k option.
To kill a specific port in Linux use the below command
sudo fuser -k Port_Number/tcp
replace Port_Number with your occupied port.
In terminal type :
netstat -anp|grep "port_number"
It will show the port details. Go to last column.
It will be in this format . For example :- PID/java
then execute :
kill -9 PID
For MAC:
lsof -n -i :'port-number' | grep LISTEN
Sample Response :
java 4744 (PID) test 364u IP0 asdasdasda 0t0 TCP *:port-number (LISTEN)
and then execute :
kill -9 PID
Worked on Macbook
To check all ports:
netstat -lnp
To close an open port:
fuser -k port_no/tcp
Example:
fuser -k 8080/tcp
In both cases you can use the sudo command if needed.
You can use tcpkill (part of the dsniff package) to kill the connection that's on the port you need:
sudo tcpkill -9 port PORT_NUMBER
The "netstat --programs" command will give you the process information, assuming you're the root user. Then you will have to kill the "offending" process which may well start up again just to annoy you.
Depending on what you're actually trying to achieve, solutions to that problem will vary based on the processes holding those ports. For example, you may need to disable services (assuming they're unneeded) or configure them to use a different port (if you do need them but you need that port more).
Kill the process that is listening to the port in question. I believe netstat shows you process ids.
If you really want to kill a process immediately, you send it a KILL signal instead of a TERM signal (the latter a request to stop, the first will take effect immediately without any cleanup). It is easy to do:
kill -KILL <pid>
Be aware however that depending on the program you are stopping, its state may get badly corrupted when doing so. You normally only want to send a KILL signal when normal termination does not work. I'm wondering what the underlying problem is that you try to solve and whether killing is the right solution.
I think the only way will be to stop the process which has opened the port.
sudo killall -9 "process name"
Shutting down the computer always kills the process for me.

Resources