tl;dr: I have an irssi proxy screen session running in the background. I'm running byobu -R -S byobu;exit in ~/.bash_profile to start a second session instead of reconnecting to the irssi session, but it starts a third session when I log in twice (e.g. once through the local terminal and once through SSH). How can I make the secon login reconnect to the first?

I had previously enabled byobu on login for my server. This worked fine, and I would get the same underlying screen session no matter where I logged in from.

However, then I added a second screen session to the server's boot:

[alex@alex-ubuntu-server ~]$ cat /etc/rc.local
#!/bin/sh -e
# [clipped out default ubuntu rc.local header]

# run an irssi proxy under screen as user alex
sudo -H -u alex screen -d -m -S irssi-proxy irssi

exit 0
[alex@alex-ubuntu-server ~]$ 

From then on, this command (which was put in my ~/.bash_profile by byobu configuration):

_byobu_sourced=1 . /usr/bin/byobu-launch -S byobu

would connect to the already existing irssi screen session, instead of creating a new session. This was obviously not ideal, so eventually I settled on the following command:

byobu -R -S byobu;exit

Then intention was to name the screen session, thus allowing a reconnect to the same name when I logged in again through e.g. SSH. However, when I login again, I get a fresh screen session instead of the existing one (as you can see in the example below, this has already happened once).

[alex@alex-ubuntu-server ~]$ screen -ls
There are screens on:
        18036.byobu     (07/07/2013 04:26:44 PM)        (Attached)
        3869.byobu      (07/05/2013 07:45:37 PM)        (Attached)
        1319.irssi-proxy        (07/04/2013 05:01:54 PM)        (Detached)
3 Sockets in /var/run/screen/S-alex.

[alex@alex-ubuntu-server ~]$ ssh localhost
Ubuntu 13.04
alex@localhost's password:
# at this point the screen redrew because of the new byobu session,
# so these weren't really one after another, as shown here
alex@alex-ubuntu-server:~$ screen -ls
There are screens on:
        6216.byobu      (07/07/2013 05:17:38 PM)        (Attached)
        18036.byobu     (07/07/2013 04:26:44 PM)        (Attached)
        3869.byobu      (07/05/2013 07:45:37 PM)        (Attached)
        1319.irssi-proxy        (07/04/2013 05:01:54 PM)        (Detached)
4 Sockets in /var/run/screen/S-alex.


I'd prefer not to switch to tmux. How can I construct a byobu/screen command that reconnects to the existing second screen session if possible, but otherwise starts a new (second) session?


You could switch the irssi process to use tmux, instead of the login process.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.