Exercise 1: A Script That Starts a Logged, Detached Session — Possible Solution ================================================================================= start-backup.sh: #!/bin/bash # Start a detached, logged screen session called "backup". cd "$HOME" || exit 1 # screenlog.0 is written here screen -dmS backup -L bash -c ' for i in 1 2 3; do date; sleep 20; done echo "Backup finished" exec bash # keep the window open afterwards ' echo "Started. Check with: screen -ls or tail -f ~/screenlog.0" Run it: $ chmod +x start-backup.sh $ ./start-backup.sh Check on it without attaching: $ screen -ls # shows 12345.backup (Detached) $ tail -f ~/screenlog.0 # watch the log fill up (Ctrl-C to stop) After about a minute the log ends with "Backup finished". Because of `exec bash`, the window stays open, so you can reattach (screen -r backup) and read the final output there too. End it with: $ screen -S backup -X quit WHY THIS WORKS AS AN ANSWER ------------------------------ It combines -dmS (detached), -L (logging) and the bash -c ... exec bash trick, and shows two ways to check progress without attaching. On newer screen versions, -Logfile ~/backup.log would give the log a clearer name.