How to shutdown jupyter notebook app (server) without using ctrl-c?
Solution 1
Starting from jupyter notebook version 5.1.0, the command
jupyter notebook stop <port number>
should shutdown the notebook server. If you don't enter a port, it defaults to 8888
as that is the default. To know on which ports the servers are currently running, you can do
jupyter notebook list
With jupyter notebook version 5.0, if it is running in the background of your terminal a solution is to do as @juanpa.arrivillaga wrote in the comments:
jobs
to see the jobs running in the background if there is only one and it is the jupyter notebook then
fg
will bring it back to the foreground at which point you can kill it with ctrl-c
. And if there are many processes in the background, for example, jobs
returns
[1] Running firefox &
[2] Running jupyter notebook &
[3] Running python calc.py &
then fg 2
brings the wanted process back to the foreground to be able to kill it with ctrl-c
, or in one step kill %2
.
Solution 2
In a terminal you could run
pkill -f -1 jupyter*
Or I have found this to work when all else fails
sudo pkill -1 -f python
Related videos on Youtube
patapouf_ai
My better answers (not necessarly the ones with the most votes): Python: How do I create a variable number of variables? Tensorflow: How to make a custom activation function with only Python in Tensorflow? What is the best way to top k pool elements instead of only the max one in Tensorflow? Numpy: Efficient way to Reshape Data for Time Series Prediction Machine Learning (Numpy) Plotting: Plotting shaded uncertainty region in line plot in matplotlib when data has NaNs Bash: How to handle quoted arguments in $@? Regex: REGEX in java with replaceall and on multiple line Math: Fit data to non-standardized Student's t-distribution in Java Colour: How can I convert RGB to CMYK and vice versa in python? Octave/Matlab: How can I apply a function to every row/column of a matrix in MATLAB? On the POLITICS OF STACK EXCHANGE, I'm sadend to learn that egos trump fair process at Stackexchange: https://meta.stackexchange.com/questions/336526/stack-overflow-is-doing-me-ongoing-harm-its-time-to-fix-it https://judaism.meta.stackexchange.com/questions/5193/stack-overflow-inc-sinat-chinam-and-the-goat-for-azazel/5197#5197 https://meta.stackexchange.com/questions/340906/update-an-agreement-with-monica-cellio https://writing.meta.stackexchange.com/questions/2301/sadly-it-is-time-for-me-to-join-the-exodus
Updated on August 31, 2022Comments
-
patapouf_ai over 1 year
I run a jupyter notebook in the background on a Mac using
>jupyter notebook &
Because it is running in the background I can't use use
ctrl-c
to kill it. Furthermore no processes seem to have the namejupyter
in the activity monitor.This github issue suggests that this no way to do it from the browser: https://github.com/jupyter/notebook/issues/1530 however it says it should be possible to do from the command line using
jupyter notebook stop <portno>
but that does not seem to work for me.How do I shutdown the jupyter server (ideally without having to search for the
pid
and then invokingkill
)?-
Matt Clark over 6 yearsIn a terminal use
ps aux
to view all running processes. If it is not in this list, it is not running. Then usekill
with the PID of the process. -
patapouf_ai over 6 yearsI can't even find the pid because no processes are named jupyter as mentionned. But in any case, I would like a more elegant way if possible.
-
juanpa.arrivillaga over 6 yearsIf there are no processes named jupyter, then jupyter isn't running. I don't know what sort of answer you were expecting, in terms of "more elegant".
-
patapouf_ai over 6 yearsIt is most definitely running because I can still access from the browser.
-
juanpa.arrivillaga over 6 yearsdo
ps aux | grep jupyter
does it return anything? -
juanpa.arrivillaga over 6 yearsAlso, you can always use
jobs
to see running background jobs. Then, usefg
to put the job back in the foreground, and then you can use ctrl-c. If there are more than one, there will be a number, e.g.[2]+ Running jupyter notebook &
then you use the number, e.g.fg 2
, or just kill it directlykill %2
-