大网数据广告活动
服务器运维问答

Byobu creating new session on every connection

· 52CE 我爱测

Every time I connect to my Ubuntu 17.10 machine with byobu-enable turned on, I get a new "session" rather than it reusing my existing sessions. On connect: Byobu sessions... 1. tmux: foo: 3 windows (created Sun Jan 28 10:23:59 20…

问题原文

原帖链接 · djmarcin · CC BY-SA 3.0

Every time I connect to my Ubuntu 17.10 machine with byobu-enable turned on, I get a new "session" rather than it reusing my existing sessions.

On connect:

Byobu sessions...

  1. tmux: foo: 3 windows (created Sun Jan 28 10:23:59 2018) [204x53] (group foo)
  2. tmux: ba: 1 windows (created Sun Jan 28 10:24:16 2018) [204x53]
  3. Create a new Byobu session (tmux)
  4. Run a shell without Byobu (/bin/bash)

Upon selecting one, say (1), I am dumped to a byobu session named e.g. _foo-20462

$ byobu list-session
_foo-20462: 4 windows (created Sun Jan 28 10:42:20 2018) [204x53] (group foo)
foo: 4 windows (created Sun Jan 28 10:23:59 2018) [204x53] (group foo)
bar: 1 windows (created Sun Jan 28 10:24:16 2018) [204x53]

The odd thing is that _foo-20462 appears to be an exact replica of the "foo" session. The only way I can figure out to kill these is byobu kill-session -t _foo-20462, but I figure there must be a way to disable this behavior, as it was not the same in prior versions of Ubuntu.

已采纳解答

原帖链接 · Kankaristo · CC BY-SA 3.0

I had the same problem and found a fix. I created an issue about this:
https://bugs.launchpad.net/byobu/+bug/1750430

I put on my detective hat and managed to fix it.


TL;DR - Either call tmux directly or revert a change in Byobu's select-session.py.


Running a plain tmux command attaches to the first session, so this is probably the easiest "fix" for this (the oddly named sessions are only created with the tmux backend, not with screen).


However, you can fix this for Byobu, too.

man byobu revealed that the part of Byobu that's responsible for selecting the session is byobu-select-session.

which byobu-select-session directed me to /usr/bin/byobu-select-session, which in turn calls /usr/libexec/byobu/include/select-session.py. These paths may be different for you (I'm on Fedora).

The line in select-session.py that creates and names the session is this one (in the function attach_session()):

os.execvp("tmux", ["tmux", "-2", "new-session", "-t", session_name, "-s", "_%s-%i" % (session_name, os.getpid())])

So, Byobu intentionally creates a session named _%s-%i, where %s is the session name and %i is the PID.

Looking into the Git blame for the line shows this commit:
https://github.com/dustinkirkland/byobu/commit/c0050ac51ee8accc3eb35862483bc40b19e3c269

Reverting the line fixes the issue:

os.execvp("tmux", ["tmux", "-2", "attach", "-t", session_name])

...but probably also removes support for "tmux grouped sessions", but I'm not entirely certain what they're used for, and I can live without them.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-01-28)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。