Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a script on an embedded device that calls screen to start if a user logs in via a ssh session...

#!/bin/sh

SCREENRUNNING=`pgrep SCREEN`

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


else

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

    sleep 2
    screen -x root/Master

fi

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.

Ideas?

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
add comment

1 Answer 1

Try using nohup before the command and the &:

  nohup command &
share|improve this answer
add comment

Your Answer

 
discard

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.