Skip to content

Instantly share code, notes, and snippets.

@rafidka
Last active December 26, 2019 23:54
Show Gist options
  • Save rafidka/a764fa910428141bfc00aeea087af3a5 to your computer and use it in GitHub Desktop.
Save rafidka/a764fa910428141bfc00aeea087af3a5 to your computer and use it in GitHub Desktop.
Run Jupyter notebook as a background process, redirecting stdout and stderr to files
echo Check whether Jupyter Notebook is already running...
# You need to update the path in this line to point to where your jupyter-notebook lives.
ps aux | grep '/home/rafidka/.pyenv/versions/3.6.8/bin/jupyter-notebook' | grep -vq grep
if [ $? -eq 1 ]; then
echo 'Jupyter Notebook is NOT running; starting it in a background process...'
curr_path=`pwd`
mkdir -p notes
cd notes
jupyter notebook --no-browser --port=9001 > $curr_path/stdout.txt 2>$curr_path/stderr.txt &
cd $curr_path
else
echo Jupyter Notebook is already running.
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment