Last active
August 29, 2015 14:00
-
-
Save soxofaan/6f4d79a8b98954536093 to your computer and use it in GitHub Desktop.
Gnu screen trick to launch ipython notebook within screen session non interactively
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# set -x | |
# set -e | |
sessionname=ipython-notebook | |
if screen -list | grep $sessionname ; then | |
echo "Screen session $sessionname is already running." | |
echo "not doing anything" | |
else | |
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!" | |
fi | |
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