Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Gnu screen trick to launch ipython notebook within screen session non interactively
# set -x
# set -e
if screen -list | grep $sessionname ; then
echo "Screen session $sessionname is already running."
echo "not doing anything"
echo "Starting iPython notenbook in screen session '$sessionname'"
# A bit of explanation:
# -dm: start screen in "detached" mode
# -S: give the session a name
# bash -c 'source ....': launch a bash shell and source virtual enviroment settings before launching ipython
# Now, pick one of the following options:
### Use standard/system wide iPython notebook
screen -dm -S $sessionname ipython notebook
### Use iPython from a virtualenv.
# screen -dm -S $sessionname bash -c 'source virtualenv/bin/activate; ipython notebook'
### Use iPython form Anaconda environment
# screen -dm -S $sessionname bash -c 'source activate ipython2; ipython notebook'
echo "iPython Notebook should be running now, have fun!"
echo "Reattach to the screen session (e.g. to shut down) with:"
echo " screen -r $sessionname"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.