I'd like to use screen to keep ssh sessions alive on my server. It would be nice if I could automatically resume any running session for my user when I log in. The straightforward way to do this would be adding "screen -r" to my .bashrc, and this seems to work fine. I'm just wondering if this will break anything under conditions which I haven't tested yet. Anyone with experience here who can tell me whether this is what I should do?
Make sure you only do this on interactive shells. Bash sources
This won't easily let you run different screen sessions in different terminals.
You'll need to detach from screen, then exit the parent shell to log out. This can be resolved by using
If you start a shell other than a login shell, you'll be put into screen, which is not what you'd want most of the time. I would at least restrict this to when you're running directly in an interactive ssh session, with something like the following in your
Be careful when you do complex things with your
What I recommend is to not modify your shell initialization files on the server, but instead run screen explicitly from the client, as in
(You would probably create a shell alias or desktop environment shortcut on the client.) That way you can easily choose not to run screen, specify an alternate session name and so on.
Your X server startup scripts often start a new shell, e.g. if you're logging in using gdm using the "User Defined Session".
I think anything that doesn't exit might cause your X startup to hang. That would include