How to start ipython notebook server at boot as da

2019-02-02 12:07发布

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条回答
一夜七次
2楼-- · 2019-02-02 12:23

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楼-- · 2019-02-02 12:35

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.

查看更多
走好不送
4楼-- · 2019-02-02 12:42
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

查看更多
登录 后发表回答