How to create screen session on startup with command that doesn't end when command finishes
Two ways. Either invoke a shell to run the script, which then replaces itself (using the
exec builtin) with an interactive shell when the script is done
screen -dmS test bash -c '~/tmp/runserver.sh; exec bash'
or keep your current screen command and put exec bash in your runserver.sh script.
#!/bin/bash node ~/dev/mouser/app.js exec bash
(On a side note, there's no point in having an extension on a script. It will just give you dependency headaches later if you rewrite it in another language. If you look in /bin and /usr/bin, you'll find a lot of sh, bash and python scripts; none of which have a .sh, .bash or .py extension)
Related videos on Youtube
Csabi Vidó 5 months
I want to edit my rc.local file to start up a few server sessions each in it's own GNU screen. However, whenever I stop a server, the screen terminates.
Currently I have:
screen -dmS test ~/tmp/runserver.sh
with this inside runserver.sh:
How do I get the screen to stay alive after the passed in command or script terminates?