Skip to content

Instantly share code, notes, and snippets.

@spestana
Last active April 18, 2019 16:15
Show Gist options
  • Save spestana/5d5ec0a9c210dde89fc21326fac90f29 to your computer and use it in GitHub Desktop.
Save spestana/5d5ec0a9c210dde89fc21326fac90f29 to your computer and use it in GitHub Desktop.
template for closing port forwarding connection with remote jupyter notebook
#!/bin/bash
# Find the jupyter notebook running on the server and shut it down:
ssh -l <USERNAME> <SERVER> 'jupyter notebook stop $(jupyter notebook list | grep -E -o 'localhost:[0-9]{4}' | grep -E -o '[0-9]{4}')'
# Find port forwarding process ID to kill on the local machine:
pid=$(ps -ef | grep ssh | grep ? | awk '{print $2}')
kill $pid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment