Screen: Run processes in the background on a Linux server

Submitted by Peter Majmesku on Mon, 08/29/2016 - 20:35

The program "Screen" can run processes in background on a Linux server.

This starts an new background session with name "your-screen-name"

screen -S your-screen-name

To save the screen and return to the terminal, type Ctrl+A+D (Ctrl+A is the hint for screen that you want to do something and "D" then "d"etaches from the session without stopping it).

Restore your screen :

screen -d -r your-screen-name

List all available screen sessions:

screen -ls

Type screen -list or -ls to identify the detached screen session.

$ screen -list 
    There are screens on: 
         20751.Melvin_Peter_V42  (Detached)  

Note: 20751.Melvin_Peter_V42 is your session id.

Quit a screen session: 

screen -X -S [session id you want to kill] quit

Or just type


if you are attached in your screen session.

Linux Bash: Force writing console output to a file

Submitted by Peter Majmesku on Mon, 08/29/2016 - 20:34

Sometimes this command just does not write content to a file by the ">" operator:

myprogram do --something > my-file-with-the-output.txt

Then you can you a small Linux default program called "tee". Example usage:

myprogram do --something | tee my-file-with-the-output.txt

Tee allows you also to use some option as "-a" to extend the file's content's instead of replacing them.

Subscribe to Bash