Last active
April 18, 2019 16:15
-
-
Save spestana/5d5ec0a9c210dde89fc21326fac90f29 to your computer and use it in GitHub Desktop.
template for closing port forwarding connection with remote jupyter notebook
This file contains 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/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