19
votes

I love ipython, especially the notebook feature. I currently keep a screen session running with the notebook process in it. How would I add ipython's notebook engine/webserver to my system's (CentOS5) startup procedures?

3

3 Answers

12
votes
vi /usr/lib/systemd/system/ipython-notebook.service
#put the following in there.
-----------------8<------------------
    [Unit]
    Description=IPython notebook

    [Service]
    Type=simple
    PIDFile=/var/run/ipython-notebook.pid
    ExecStart=/usr/bin/ipython notebook --no-browser
    User=ipynb
    Group=ipynb
    WorkingDirectory=/home/ipynb/notebooks

    [Install]
    WantedBy=multi-user.target
-----------------8<------------------

# useradd ipynb
# su - ipynb # go there create notebooks dir
# systemctl daemon-reload
# systemctl enable ipython-notebook
# systemctl start ipython-notebook

credits

6
votes

Maybe put something like:

cd /path/to/notebookdir && ipython notebook --no-browser &

in /etc/rc.d/rc.local? That's the 'easy' way, fine I think if it's just your personal machine, but if it's a 'real' server you should probably do a full Sys V-init thing; see this question for more

3
votes

I assume you don't want to run the program as root. So this is my modified version that runs as <username> (put in /etc/rc.local before the exit 0 line):

su <username> -c "/usr/bin/ipython notebook --no-browser --profile <profilename> &"

You can check to make sure your ipython is at that path with which ipython. Though you may just be able to get away with not putting the full path.