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?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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
回答2:
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:
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.