Monday, December 17, 2012

Reconnecting to Screen

As I have previously mentioned, I use GNU Screen a lot. The most typical way I use it is via a PuTTY ssh session from Windows. In these cases, I have a PuTTY profile, that gets rid of scroll bars, and automatically reconnects to screen using 'screen -x'

Unfortunately, 'screen -x' does not start a screen session if there isn't one available. This isn't a problem except when I reboot the box that hosts my screen sessions, and then because of two factor authentication, I have to bumble around (ssh in, start screen, and then connect with the correct PuTTY profile, etc).

A simple solution to this would be to add screen to your crontab with @reboot but the easy solution is not seemless. Specifically, on Ubuntu the default /bin/sh is 'dash'. When cron executes dash, no TTY is allocated which causes screen to fail. So try making your crontab something like:
SHELL=/bin/bash
@reboot         screen -d -m 1> /dev/null 2>&1

No comments:

Post a Comment