At times, it is required to run your scripts or commands in the background rather than doing it directly over SSH. There can be a situation when your internet connection can get unstable and things get shaky. Every important stuffs you execute in your server is preferred to be done via screen. screen is often referred to as ‘An admins best buddy’
When screen is called, it creates a single window with a shell in it
(or the specified command) and then gets out of your way so that you can use the program as you normally would.
To install screen in a red-hat based distro, run the following :
# yum install screen
– To start a new screen with the name – test , run the following :
# screen -S test
The above command opens a new window and you can execute/run any commands there. This will stay in the background. You can detach yourself from the screen by pressing the following keys
Ctrl + a followed by Ctrl + d
– To list all the running screens at any point of time, run the following :
# screen -ls
– To re-enter into an already detached screen,
# screen -x test
This will re-attach your window to the screen test, which was created earlier.
– Check out the further options available in screen by :
# man screen