<div dir="ltr"><div>I do the same with screen ... <br></div><div><br></div><div>I have a screen session always on my home server with connections/sessions to <br></div><div>other servers and such.</div><div><br></div><div>I scripted this over a decade ago, by having a shell script called checkscreen</div><div>run from .bash_profile with the following</div><div><br></div><div>TMP=/tmp/screen.$$</div><div><br></div><div>screen -ls > $TMP<br><br>if grep -q "No Sockets" $TMP; then<br>  # There are no screen sessions. Create one<br>  echo "There are no screen sessions. Creating a new one!"<br>  echo -n "Hit Enter to continue ..."<br>  read NL<br><br>  rm -f $TMP<br>  screen -S main<br>elif grep -q "1 Socket " $TMP; then<br>  # There is a main session. Reattach it silently.<br>  echo "Reattaching to existing screen session."<br>  echo <br>  echo "Hit Enter to continue ... \c"<br>  read ENTER<br>  rm -f $TMP  <br>  screen -d -r<br>else<br>  # List the sessions<br>  echo "You have the following screen sessions:"<br>  rm -f $TMP<br>  screen -ls<br>fi</div><div><br></div><div>So, if a session exists, I connect to it. If no session exists, such as when the <br></div><div>server is rebooted, new screens are created according to what I have in .screenrc.</div><div><br></div><div>There is no xterm if that is what you want though. These are all shell sessions. <br></div></div>