How to kill a running process ?
I have started a Plone server via the repl.it shell.
I have closed the repl.it page with the server still running: http://ploneinrepl--gotcha1.repl.co
If I open the repl again and open the shell, how can I kill the running process ?
It looks like you can use the pidof
command to identify the process id and then the kill
command to stop it. I had an Express (Node.js) server that I couldn't kill and in the console I kept seeing the error EADDRINUSE (the port was already in use) due to Repl.it running my code automatically.
So pidof node
and then kill <pid>
worked for me. Note that in my case there were multiple pids for node so I used the piped commands below to kill all node processes
pidof node | awk 'BEGIN { RS = " " } { print $1}' | while read line ; do kill $line ; done
@alejo4373 This is the best fix i seen!
In Repl, its a little hard to kill a process, in a linux machine i think its ctrl-c
You won't be able to kill the process from the shell. The two easiest ways to do it are:-
- Wait for 1 hour for it to kill itself.
- Write 1 or 2 words deliberately to make the code buggy, then restart.
@TheDrone7 Thanks for your answer.
Trying 2, I have saved broken code for main.py and clicked the green start button.
This nicely fails in the python interpreter but does not kill the server started via the shell.
@TheDrone7 which I could do if I did not have quit the repl opened in browser.
When I get back to my repl, I get a new shell without access to the running process... or at least, I do not know how to get access to it.
Which is why I ask how to kill it.
@TheDrone7 @gotcha1 +1 do it
@gotcha1 If I am understanding you correctly then I believe there is no efficient way to kill it. But if you wait for a while the program will stop responding and in a way kill itself (like what TheDrone7 said).
@PythinPython Can't you do top
in the shell, get the pid of the process, and type kill [pid]
?
@Vandesm14 I had not thought of top
. However, neither top
, neither ps
commands are available in the shell.
@Vandesm14 that would require superuser permissions and repl.it doesn't give you that.
@PythinPython the repl won't go down on it's own either if started using the shell, unlike the normal repls, it stays up for a little longer than normally started ones. So the quicker way would be to fork it and continue working in the new one.
@TheDrone7 I have forked the repl as suggested.
For the record, if I run Plone in daemon mode and I write down its pid, I am able/allowed to kill
it.
just type kill 1
in the shell
Im super late, but if someone still cares, run
kill 1
to fix all your problems!@milenakos Thank you! It works good!