Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Upstart file (Ubuntu) for Jupyter / IPython notebook
start on filesystem or runlevel [2345]
stop on shutdown
description "Jupyter / IPython Notebook Upstart script"
script
export HOME="/home/phil/Notebooks"; cd $HOME
echo $$ > /var/run/ipython_start.pid
exec su -s /bin/sh -c 'exec "$0" "$@"' phil -- /home/phil/Enthought/Canopy_64bit/User/bin/jupyter-notebook --config='/home/phil/.jupyter/jupyter_notebook_config.py'
end script
@whophil

This comment has been minimized.

Copy link
Owner Author

@whophil whophil commented Oct 13, 2015

To be placed in /etc/init/ with 644 permissions

@whophil

This comment has been minimized.

Copy link
Owner Author

@whophil whophil commented Nov 17, 2015

Replaced
exec /home/phil/Enthought/Canopy_64bit/User/bin/jupyter-notebook --config='/home/phil/.jupyter/jupyter_notebook_config.py'

with
exec su -s /bin/sh -c 'exec "$0" "$@"' phil -- /home/phil/Enthought/Canopy_64bit/User/bin/jupyter-notebook --config='/home/phil/.jupyter/jupyter_notebook_config.py'

So that Jupyter runs as user phil (or of your choosing) instead of as root.

@MilesMcBain

This comment has been minimized.

Copy link

@MilesMcBain MilesMcBain commented Apr 10, 2016

Highly useful. Thankyou!

@evolgenomology

This comment has been minimized.

Copy link

@evolgenomology evolgenomology commented Dec 21, 2016

Hi there,

I've got a problem when trying to get into my notebook server run via upstart on Ubuntu. Everything is just fine when I start jupyter from the terminal on my workstation like this
jupyter notebook --no-browser. I can happily log in via a browser on my other computer.
(Also works when I do it as root.)
However, when using this line in an upstart script
start on filesystem or runlevel [2345] stop on shutdown description "Jupyter / IPython Notebook Upstart script" script export HOME="/home/philipp/Dropbox/ipython_notebook"; cd $HOME echo $$ > /var/run/ipython_start.pid exec jupyter notebook --no-browser end script

the server does not accept the password and will not allow me to log in. I tried some variants of what you suggest as a script up there, but to no avail. Am a bit at a loss here, and would appreciate any hint to what I am doing wrong.

Thanks

Philipp

@confiq

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment