How to restore and preserve multiple Screen sessions?



A new problem and another quick solution!

As usual while working on many server (imagine 20 Linux/Unix machines), it is often difficult to remember all machine names, their configuration and yet to keep all individual setups at fingertips.
The obvious choice on Linux is using SCREEN multiplexer.

But there are some limitations :(
What if you the machine running Screen sessions reboots or shuts down? Starting each and individual session after your screen session machine is up, is very time consuming and more or less very uncomfortable during stressful times ( using alternate wordings for being lazy :) )

I wrote following (very simple wrapper) scripts on top of Screen commands to bring up all sessions as quickly as possible with single Screen command. It should be noted that all machine names and other terms are generalized in below session commands.

[root@techsutram.com screen-sessions]# ls
Setup_1.ssh  Setup_2.ssh  Setup_3.ssh  Setup_4.ssh
[root@techsutram.com screen-sessions]# cat Setup_1.ssh
screen -t DRIVER_EXECUTION ssh root@launcher.techsutram.com
screen -t node1 ssh root@node1.techsutram.com
screen -t node2 ssh root@node2.techsutram.com
screen -t node3 ssh root@node3.techsutram.com
screen -t node4 ssh root@node4.techsutram.com

[root@techsutram.com screen-sessions]# screen -S _SETUP_1_ -c ~/screen-sessions/Setup_1.ssh


It will ask for passwords (if required) for each individual machines (^a" and select node? ).
Hopefully it helps! At least it will help me sometime in future.

Note: We at TechSutram take our ethics very seriously. More information about it can be found here.
Mandar Pise Opinions expressed by techsutram contributors are their own. More details

Mandar is a seasoned software professional for more than a decade. He is Cloud, AI, IoT, Blockchain and Fintech enthusiast. He writes to benefit others from his experiences. His overall goal is to help people learn about the Cloud, AI, IoT, Blockchain and Fintech and the effects they will have economically and socially in the future.

No comments:

Post a Comment

    Your valuable comments are welcome. (Moderated)