Skip to content
← Back to Community
How to kill a running process ?
Profile icon
gotcha1

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 ?

Voters
Profile icon
Platn
Profile icon
Poncho-dotnet
Profile icon
Elias07w
Profile icon
Jashanth
Profile icon
alejo4373
Profile icon
DSACharlie
Profile icon
gotcha1
Comments
hotnewtop
Profile icon
milenakos

Im super late, but if someone still cares, run kill 1 to fix all your problems!

Profile icon
Skiicats

@milenakos Thank you! It works good!

Profile icon
alejo4373

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
Profile icon
selectthegang

@alejo4373 This is the best fix i seen!

Profile icon
Masy

In Repl, its a little hard to kill a process, in a linux machine i think its ctrl-c

Profile icon
TheDrone7

You won't be able to kill the process from the shell. The two easiest ways to do it are:-

  1. Wait for 1 hour for it to kill itself.
  2. Write 1 or 2 words deliberately to make the code buggy, then restart.
Profile icon
gotcha1

@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.

Profile icon
TheDrone7

@gotcha1 if you've started it via shell Ctrl + C to kill it.

Profile icon
gotcha1

@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.

Profile icon
TheDrone7

@gotcha1 the only way I can think of now is to fork the repl and use the new one after deleting the old one.

Profile icon
a5rocks
Profile icon
PythinPython

@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).

Profile icon
Vandesm14

@PythinPython Can't you do top in the shell, get the pid of the process, and type kill [pid]?

Profile icon
gotcha1

@Vandesm14 I had not thought of top. However, neither top, neither ps commands are available in the shell.

Profile icon
TheDrone7

@Vandesm14 that would require superuser permissions and repl.it doesn't give you that.

Profile icon
TheDrone7

@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.

Profile icon
gotcha1

@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.

Profile icon
TheDrone7

@gotcha1 well that's good news. Last time I tried kill didn't go well for me.

Profile icon
DeLevo

just type kill 1 in the shell