Server Fault is a question and answer site for system and network administrators. 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 have a script on an embedded device that calls screen to start if a user logs in via a ssh session...



if [ -z "$SCREENRUNNING" ]; then

    echo "Screen not running so let's start the Master session
    sleep 2
    screen -dmS Master
        sleep 2
        screen -x root/Master


    echo "Screen is already running let's connect to existing session"

    sleep 2
    screen -x root/Master


However this keeps the calling script active till the screen session exits,even if it's detached.

What I want to do is have the calling script finish and exit while the screen session stays active. I've tried daemonising the screen -x lines and adding an & to the end of the screen -x lines neither of which work properly.


If you don't let the script finish and exit you end up with orphaned instances each time you log onto the device afresh, i.e. each logon generates an instance of the script that will only exit when screen is fully shut down.

As it's an embedded device so nohup isn't available.

share|improve this question
Why do you need the calling script to finish? Is it doing more after starting screen? – Grant Sep 24 '12 at 19:49

Try using nohup before the command and the &:

  nohup command &
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.