20

我喜欢 ipython,尤其是 notebook 功能。我目前保持一个屏幕会话与其中的笔记本进程一起运行。如何将 ipython 的笔记本引擎/网络服务器添加到我的系统 (CentOS5) 启动程序中?

4

3 回答 3

12
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

学分

于 2016-03-10T11:17:25.240 回答
6

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

于 2013-01-12T22:45:59.403 回答
3

我假设您不想以 root 身份运行该程序。所以这是我修改后的版本,运行方式为<username>(放在行/etc/rc.localexit 0):

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

您可以检查以确保您的 ipython 位于带有which ipython. 尽管您可能不走完整路径就可以逃脱。

于 2015-09-07T21:41:26.840 回答