preface

Small knowledge, big challenge! This paper is participating in theEssentials for programmers”Creative activities.

Have you ever tried SSH to a server and tried to run a code that took a long time to execute, but once you shut down the shell, your code stopped running and didn’t run on the server as much as expectedscreenYou can solve this problem and keep your code running on the server! 🕙 ⏱


What is screen?

Screen is a multiple window manager.Copy the code

How do I use screen?

Create a screen 🖥 2. Run the program on this screen 🏃🏿♂️ 3. Switch between screens 4. Close the screenCopy the code
1. Create screen 🖥

First install Screen based on your system type

Sudo apt-get install screen/yum install screen

Screen-s screendemo 👈 Create a screen called ScreenDemo that will automatically switch to screenDemo

Screen-ls Displays existing Windows

There is already a screenDemo window, and now the code is running in screenDemo window, now you can run the code you want 🚗.

2. Return to the main session 🔙

If we want the screendemo to run in the background and return to the main session for other tasks, we can press CTRL + A + D to return to the main session.

If you set up a shortcut key this area may cause conflict, should change or close your shortcut key, eliminate conflict. 💣

Now let’s look at the screen list again with screen-ls

It’s already running in the background (it doesn’t matter if you close your shell or shut down your computer) and it’s already running on the server.

3. Return to screendemo 🏃 ♀ ️

Screen-r screendemo can go back

⚠👹 There is no screen to be resumed matching **** Enter the command screen -d screendemo and try again.

4. Close ScreenDemo 👋

Each screen running in the background consumes some system resources. If disabled, exit can be used