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.
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.