Answer the question
In order to leave comments, you need to log in
How to make a good autostart program in Linux?
I decided to make myself a small environment to learn python. I created a virtual machine with ubuntu, installed pyenv, there is anaconda, well, actually IPython Notebook is in it.
I realized that I want the server with IPython Notebook to start when I boot the virtual machine, but at the same time, so that it is not in the background somewhere, but so that you can attach to it and see what it says, what errors displays if so.
Made myself a very crooked solution for this. Made automatic login in tty2 and added to the .bashrc
following lines:
if [ "$(tty)" = '/dev/tty2' ]; then tmux; fi
if [ -z "$(ps -e | grep 'jupyter-note')" ]; then [ -n "$TMUX" ] && command -v tmux >/dev/null && ./notebook.sh; fi
Answer the question
In order to leave comments, you need to log in
Supervisor: A Process Control System is a good tool for this. I recommend using it.
If it's correct, then depending on what kind of Ubuntu you have, you need to write either a unit to systemd or to upstart.
For upstart it would look something like this ( /etc/init/ipython-notebook.conf)
# Запуcкаем программу в tty2
#
# Дополнительно нужно убедиться, что на tty2 больше ничего не стартует
# (хорошей идеей будет прибить /etc/init/tty2.conf)
start on stopped rc RUNLEVEL=[2345]
stop on runlevel [!2345]
respawn
exec /usr/bin/setsid sh -c 'exec notebook.sh <> /dev/tty2 >&0 2>&1'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question