Technology and General Blog

The system or server administrator usually wants to keep a terminal session alive for keeping a method or application managing. Even so, when we close the SSH relationship or do not mail any information and facts to the server, the terminal session will near. To prevent the server to auto-close the terminal session, we can complete some configuration. This put up will give two means to keep a terminal session alive:

  1. By placing up the configuration file
  2. Using Monitor

Properly, there is a rapid way to prevent the server from closing the session. We can only incorporate the following parameter to the SSH command and log in to the server.

$ ssh -o ServerAliveInterval=60 <user>@<ip>

The router will send info just about every 60 seconds to retain the server session alive by working the earlier mentioned command.

But, if you do not want to established it each individual time whilst logging in, you can choose the default configuration in the configuration file of SSH.

Now, let us see how we can set up the configuration information to retain the terminal session alive.

Continue to keep a Terminal Session Alive by Location Up the Configuration File

To edit the configuration file of SSH, sort the command specified down below:

$ sudo nano $Household/.ssh/config

The previously mentioned command will generate the configuration file and open up the file in the nano editor to let you edit it even if it does not exist.

After opening it in a nano editor, insert the articles offered under in the configuration file:

Host *
ServerAliveInterval 60

The higher than configuration will retain on sending the alive sign just after just about every 60 seconds for all the hosts.

Just after getting this configuration, we need to change the file’s mod working with chmod to grant read through and writable permissions. To do so, type the command provided beneath:

$ chmod 600 $Household/.ssh/config

When you log in to the server, the terminal session won’t automatically close. Instead, the configuration file will continue to keep sending the alive sign just after the unique interval established in the configuration file to continue to keep the terminal session alive.

Below arises an additional challenge. What if some procedures have to have to operate for hrs. Does the shopper device also need to continue to be ON to continue to keep sending the alive signal to the server?

Well, in the higher than-offered technique, sure. The consumer equipment has to continue to be on. But, there is one more way to retain the terminal session alive.

Let us discover a superior and far more productive way to retain the terminal session alive.

Preserve a Terminal Session Alive Applying Display

The Display is an software employed to continue to keep the terminal session alive even when the customer machine is rebooted or turned off. This software can be applied to hold the terminal session of the server alive for hours until eventually the process running in the session is completed.

Let us jump into the course of action and see how to install and use the display screen to continue to keep a terminal session alive.

Set up of Display screen

Initial of all, login to the server using SSH:

Following logging into the server’s machine, update the server system’s repository cache:

And operate the installation command of the screen utilizing the command furnished under:

$ sudo apt put in screen

The set up of the monitor can be confirmed using the command supplied under:

Now, when the screen software is installed on the server. The use is uncomplicated.

Use of Screen

To create a new session utilizing the display, you can only run the “screen” command to start out a new session.

You can also deliver a identify to the session even though developing a new session, as proven down below:

The over commands will build a new session in which you can run or start any system of your option.

For illustration, we want to up grade the system’s installed offers.

Now, although it is jogging, you can detach from the session making use of the keyboard shortcut keys CTRL+A+D, and all the processes will preserve on performing guiding the scene even if you log out from the server working with SSH.

To link again to the session, log back again into the server applying SSH yet again if you are logged out and use the command given below:

But if there are various sessions, you require to kind the session ID, and you can get the session ID employing the subsequent command:

From the provided listing of sessions, pick out the session to which you want to be part of, and give its session ID as demonstrated underneath:

This approach is how you can put in and use the screen to retain the terminal session alive for hrs until eventually a approach is concluded.


This publish is all about how to continue to keep a terminal session alive. It includes a transient expertise about the configuration of SSH for sending alive indicators immediately after a unique interval of time. This post also gives a thorough process on how to install and use the display software to maintain the terminal session alive.

Leave a Reply

Your email address will not be published. Required fields are marked *