Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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/

with this inside

node ~/dev/mouser/app.js

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

share|improve this question

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/; exec bash'

or keep your current screen command and put exec bash in your script.

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)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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