4

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:

node ~/dev/mouser/app.js

How do I get the screen to stay alive after the passed in command or script terminates?

4

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)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.