Start Unix screen, Run command, Detach [duplicate]

Solution 1:

This script prevent session killing:

screen -dmS test bash -c 'echo waiting 5 senconds...; sleep 5; exec bash'

Regards!

Solution 2:

to run a command and detach from the session:

screen -d -m runSomething