Running remote jobs after disconnecting
screen
When running long jobs remotely (file transfer, heavy computational jobs, etc), it's sometimes helpful to be able to start the job and disconnect from the remote system (while the jobs continues to run).
screen
is one tool that can be used to acomplish this. The usual procedure
is to connect to the remote system, start a screen
session, start the job,
disconnect from the screen
session, and log-out.
start session | screen |
disconnect from session |
<ctrl-a d> (control a + "d") |
re-connect to existing session | screen -r |
check for existing sessions | screen -ls |
quit screen session | exit |
example screen
file transfer
localsys> ssh [meyer@xtal200.harvard.edu](mailto:meyer@xtal200.harvard.edu)
connect to remote system
crystal> screen
# start screen session
crystal> scp -r -p meyer@remote_site:~/data/ ~/data/
# start data transfer
crystal> <ctrl-a d>
# disconnect from screen session
crystal> logout
# disconnect from remote system
localsys>
# all done
example screen
computational job
localsys> ssh [meyer@xtal200.harvard.edu](mailto:meyer@xtal200.harvard.edu)
connect to remote gateway system
crystal> ssh abacus
# connect to your workstation; replace abacus
with the
name of your workstation
abacus> screen
# start screen session
abacus> ./data_processing_script.sh
# start processing data
abacus> <ctrl-a d>
# disconnect from screen session
abacus> logout
# disconnect from workstation
crystal> logout
# disconnect from gateway system
localsys>
# all done
For more information, see the screen manual.
tmux
tmux
is a newer alternative to screen
. The same approach is used -
connect to the remote system, start a tmux
session, start the job,
disconnect from the tmux
session, and log-out.
start session | tmux |
disconnect from session |
<ctrl-b d> (control b + "d") |
re-connect to existing session | tmux a |
check for existing sessions | tmux ls |
quit tmux session | exit |
example tmux
file transfer
localsys> ssh [meyer@xtal200.harvard.edu](mailto:meyer@xtal200.harvard.edu)
connect to remote system
crystal> tmux
# start tmux session
crystal> scp -r -p meyer@remote_site:~/data/ ~/data/
# start data transfer
crystal> <ctrl-b d>
# disconnect from tmux session
crystal> logout
# disconnect from remote system
localsys>
# all done
example tmux
computational job
localsys> ssh [meyer@xtal200.harvard.edu](mailto:meyer@xtal200.harvard.edu)
connect to remote gateway system
crystal> ssh abacus
# connect to your workstation; replace abacus
with the
name of your workstation
abacus> tmux
# start tmux session
abacus> ./data_processing_script.sh
# start processing data
abacus> <ctrl-b d>
# disconnect from tmux session
abacus> logout
# disconnect from workstation
crystal> logout
# disconnect from gateway system
localsys>
# all done
For more information, see the tmux homepage.