Automatically (or more easily) reconnect to a screen session after network interruption

后端 未结 6 1111
旧巷少年郎
旧巷少年郎 2021-01-30 00:20

ADDED: This question is now, I believe, subsumed by this one: Using GNU Screen completely transparently and automatically

See also this related question:
https://s

6条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-30 00:36

    I've been working on something similar but not quite got there, your solutions have solved my problem so here's my suggestion:

    ssh -t server.com "screen -S foo -rd || screen -S foo"
    

    This just tries to open the existing screen named foo and if it doesnt exist, creates it. I'll put this in a launcher on my laptop, so when the wireless network goes I can just open where I left off.

    Just noticed that the default screen shell is a bit weak, so an improvement which sets up your home environment a little better is:

    ssh -t server.com "screen -S foo -rd || screen -S foo bash -l"
    

提交回复
热议问题