Run a background process using Screen

Start a new session:

screen -S session-name

Start a long-running foreground application:

while true; do echo $(date); sleep 2; done

Detach from the session:

ctrl-a + d

i.e. press ctrl-a, then press d.

List all running sessions:

screen -ls

Reattach to the session:

screen -dr session-name

To end the session, terminate the foreground application using ctrl-c, then type exit.