How can I get screen to execute a command and then detach (That is, automatically in a single script without further input beyond initially starting the script)? e.g. I run myscript.sh and it automatically starts a screen session, executes a command, then detaches.
To run a single command in screen and detach, you may try:
To run multiple commands, try:
Please note that when a program terminates, screen (per default) kills the window that contained it.
If you don't want your session to get killed after script is finished, add
To list all your sessions, try:
Related: Start Unix screen, Run command, Detach.