Exercise 3: A Checklist for Long Jobs on Remote Servers — Possible Solution ============================================================================= Before starting [ ] Is screen installed? (screen -v) [ ] Is this really a one-off job? If it should run at boot or restart when it fails, make it a systemd service instead. Starting [ ] Start a named session, with logging: screen -S name -L [ ] Name the window (Ctrl-a A) and redirect or log important output [ ] Turn on silence monitoring (Ctrl-a _) to hear when it finishes Checking progress [ ] Detach with Ctrl-a d — never type exit [ ] From outside: screen -ls, tail screenlog.0, or screen -S name -X hardcopy /tmp/snap.txt Surviving a disconnection [ ] Reconnect and run screen -ls [ ] Detached -> screen -r name; Attached -> screen -d -r name [ ] If sessions keep vanishing at logout, check KillUserProcesses If I forgot to use screen [ ] Ctrl-Z, bg, then reptyr PID inside a screen window [ ] No reptyr? Ctrl-Z, bg, disown %1 (and accept I can't watch it) Cleaning up [ ] Confirm the job finished successfully (scroll back or read the log) [ ] screen -S name -X quit, then screen -wipe [ ] Delete old screenlog files you no longer need WHY THIS WORKS AS AN ANSWER ------------------------------ It turns the course into a routine you can follow without thinking, including what to do when something has already gone wrong. Your own list may differ; what matters is covering all four stages.