I have ipython notebook running properly but I'd like to run it as a service (start, stop, restart) so that I don't have to start it manually every time I login with SSH.

How can I do that?

  • On which distribution, and which init system? – Chris Down Sep 16 '15 at 10:01
  • Scientific Linux SLC 6.7 – Cedric H. Sep 16 '15 at 10:16

I would suggest using supervisord. I'm using jupyterhub through supervisord.

Supervisord spawns your program as it's child, and you can configure it to restart it if it dies, so you will always have the service up. It has some configuration options but it's pretty straight forward. You can even have a http interface from where you can stop or start the programs it keeps.

A basic definition, in supervisord.conf, for your program would look like the following.

command=/usr/local/bin/ipython notebook --ip --port 8080
stderr_logfile = /var/log/supervisord/ipython_notebook-stderr.log
stdout_logfile = /var/log/supervisord/ipython_notebook-stdout.log


I tried to do it with systemd also, and this is what I came up with.

Create the file: /etc/systemd/system/ipython.service. The file contents:


ExecStart=/usr/local/bin/ipython notebook --ip --port 8080


I didn't check all the parameters for the ipython notebbok, but there should be one that let's you specify your home. If not a parameter that most certainly you could find it in ptofile. You should also add that.

Then you have to enable the service:

systemctl enable /etc/systemd/system/ipython.service

and start it:

systemctl start ipython.service

I'm not really sure, but seeing that it is WantedBy multi-user.target, you should have it up aster a system restart, but I'm quite new to systemd so I might be wrong :)

  • That looks good but I'm using Python 3.4 and supervisor is not compatible with Python 3 :( – Cedric H. Sep 16 '15 at 11:52
  • Do you use systemd? I'm gonna post a service file for systemd also. – primero Sep 16 '15 at 13:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.