I have a script that creates a new screen and executes a command (dev webserver) in it.
screen -S webserver -dm sh launch_webserver.sh
However, when the command is done (or webserver quits), the screen is destroyed. How can I avoid that ?
gnu-screen
I have a script that creates a new screen and executes a command (dev webserver) in it.
screen -S webserver -dm sh launch_webserver.sh
However, when the command is done (or webserver quits), the screen is destroyed. How can I avoid that ?
Best Answer
What do you want to happen when the command is finished? The screen session ends when there are no more running commands, so if you want to keep the session around, you'll have to run another command.
If you want to keep the window around and run more commands it it, run a shell when the initial command finishes.
If you want to keep the window around just to see the output, run a command that waits, such as
sleep
(with a near-infinite argument) orread
(waits until you press Enter).If you want to keep the session around but not the window, run another command. You'll have to write a screenrc file (which is a good idea anyway).
where
/path/to/webserver.screenrc
contains