Uninterrupted Linux session : screen command

Have you ever faced losing connections to a remote machine (e.g. from a putty) and you happened to be in middle of a script that took ten hours to complete. So what would you do??

Restart the script after re-connecting.

Not anymore…

Linux screen solves this problem with providing a terminal that runs on server and just exported to your putty/Terminal client. In simple terms, you are running your putty on remote machine and watching the output on your local client.

Now, if you client goes down, just chill!

Screen is running your script on remote machine.

To start a screen session:
– Login to remote machine with as you may wish.
– Run $screen
– Do you stuff

Power cut and, no net connection and your client is down.

Once power is back, just re-login to remote machine.
and issue:
$screen -r

It’ll list all screen sessions running on the remote machine. Get attached to one of the session with:

$session -r

Alternative: Move your job to background

Press ctrl+Z on your application’s active console; then do $bg && disown

Done 🙂

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: