Run Background Tasks with screen on Linux, Keeping Sessions Alive

Tech Sharing 2017-12-19
Run Background Tasks with screen on Linux, Keeping Sessions Alive

Use screen to create persistent sessions so tasks keep running after SSH disconnects. Covers install, create/resume, force-takeover, list and delete.

First install screen:

yum install screen

Then you can use:

screen -S download      create a session (e.g. for downloads)
screen -r download      resume the previous session
screen -D -r download   if it shows Attached and won''t enter, detach the previous user then enter
screen -ls              list all sessions
exit                    quit screen
screen -wipe download   delete the session