Byobu cache or restored duplicate sessions
I had exactly the same problem and solved it by updating byobu from PPA.
byobu 5.125 tmux 2.6 Ubuntu 18.04
I spent a few weeks using workaround (killing the process with tmux ls|grep ^_|...); then I fixed this issue completely by just updating byobu to 5.133:
sudo add-apt-repository ppa:byobu/ppa
sudo apt update
sudo apt install byobu
This appears to be a bug in later versions of byobu, caused when detaching or switching sessions. The bug has not been fixed yet...
Here is a workaround*. This command will get rid of the extra sessions. It was tested on Ubuntu 18.04.
# Get list of active sessions that start with an underscore, and kill them
tmux ls | grep ^_ | cut -f1 "-d:" | xargs -r tmux kill-session -t
This will get a list of byobu
/tmux
sessions, check for ones that start with an underscore, and then tell tmux
to kill them. If there are no duplicate sessions, it won't do anything, so it's safe to run.
* Pablo Bianchi posted a workaround as well, though the command they provided does not check that any duplicate session exists, so it can end up calling "tmux kill-session" without a target and end up killing your active session... It will also kill sessions that happen to have an underscore anywhere within the session name.