어려운 길을 찾았습니다tmux
나열되지 않은 다른 소켓에서 시작된 세션tmux ls
, 이는 단순히 소켓에 속한 세션에 대한 바로가기를 tmux -L default list-sessions
표시하기 때문입니다. default
(저는 사용하고 있어요tmux -L
tmux
쉘이 호출되는 환경을 상속받습니다 ..)
tmux ls
세션의 PID를 표시하지 않습니다.
$ tmux -L default ls
1: 1 windows (created Thu Mar 30 09:39:31 2023) (attached)
$ tmux -L lofa ls
0: 1 windows (created Tue Apr 25 15:12:00 2023) (attached)
2: 1 windows (created Tue Apr 25 16:25:38 2023)
순진하게 시작 시간을 기준으로 프로세스를 일치시키려고 했고, lofa
s 세션의 시작 시간이 일치하고 남은 세션 중 하나만 default
s 였기 때문에 어느 세션이 어느 세션인지 유추할 수 있었지만 default
세션 시간이 분명히 달랐습니다.
$ ps x -o lstart,pid,stat,args f
STARTED PID STAT COMMAND
Tue Apr 25 15:01:27 2023 2387795 S sshd: lynx-dev@pts/4
Tue Apr 25 15:01:27 2023 2387796 Ss \_ -bash
Tue Apr 25 15:01:33 2023 2387820 S \_ bash --rcfile /tmp/nix-shell-2387820-0/rc
Tue Apr 25 16:52:21 2023 2393925 R+ \_ ps x -o lstart,pid,stat,args f
Tue Apr 25 15:00:23 2023 2387609 S sshd: lynx-dev@pts/1
Tue Apr 25 15:00:23 2023 2387610 Ss \_ -bash
Tue Apr 25 15:11:51 2023 2389501 S \_ bash --rcfile /tmp/nix-shell-2389501-0/rc
Tue Apr 25 15:12:00 2023 2391030 S+ \_ tmux -L lofa
Tue Apr 25 14:59:32 2023 2385992 S sshd: lynx-dev@pts/0
Tue Apr 25 14:59:33 2023 2385998 Ss \_ -bash
Tue Apr 25 14:59:41 2023 2386007 S+ \_ bash /tmp/nix-shell-2386007-0/rc
Tue Apr 25 14:59:42 2023 2387528 S+ \_ tmux attach
Tue Apr 25 15:12:00 2023 2391032 Ss tmux -L lofa
Tue Apr 25 15:12:00 2023 2391033 Ss+ \_ -bash
Tue Apr 25 16:25:38 2023 2393553 Ss+ \_ -bash
Tue Jan 24 17:58:29 2023 32710 Ss tmux
Wed Apr 12 12:56:35 2023 1187196 Ss \_ -bash
Wed Apr 12 12:57:28 2023 1187935 S \_ bash --rcfile /run/user/1000/nix-shell-1187935-0/rc
Wed Apr 12 13:00:18 2023 1190971 Sl+ \_ /nix/store/ybmibj2kdfd3m1dq9rl8kcpy23av4c74-vim_configurable-9.0.0609/bin/vim -u /nix/store/7lsixnw74d45g3l6g2nfaqw80fsal5jl-vimrc
Wed Apr 12 13:02:36 2023 1191015 Ss \_ /nix/store/38db4p333ibll7r1v151yc5f6ms1fr00-bash-interactive-5.2-p15/bin/bash
Wed Apr 12 13:02:42 2023 1191725 S+ \_ bash --rcfile /run/user/1000/nix-shell-1191725-0/rc
Tue Jan 24 17:54:53 2023 22116 Ss /lib/systemd/systemd --user
Tue Jan 24 17:54:53 2023 22117 S \_ (sd-pam)
Thu Jan 26 02:42:42 2023 98296 SLs \_ /usr/bin/gpg-agent --supervised
Tue Apr 11 21:08:13 2023 1178866 Ss \_ /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
답변1
tmux list-sessions
형식 문자열을 허용합니다(참조:"형식" 섹션매뉴얼 페이지에서):
$ tmux ls -F 'socket_path: #{socket_path} | session_name: #{session_name} | server_pid: #{pid} | pane_pid: #{pane_pid}'
socket_path: /tmp/tmux-1000/default | session_name: 1 | server_pid: 32710 | pane_pid: 1187196
$ tmux -L lofa ls -F 'socket_path: #{socket_path} | session_name: #{session_name} | server_pid: #{pid} | pane_pid: #{pane_pid}'
socket_path: /tmp/tmux-1000/lofa | session_name: 0 | server_pid: 2391032 | pane_pid: 2391033
socket_path: /tmp/tmux-1000/lofa | session_name: 2 | server_pid: 2391032 | pane_pid: 2393553
또는 개행 문자를 사용하세요.
$ tmux -L lofa ls -F \
> 'socket_path: #{socket_path}
> └── session_name: #{session_name} | server_pid: #{pid} | pane_pid: #{pane_pid}'
socket_path: /tmp/tmux-1000/lofa
└── session_name: 0 | server_pid: 2391032 | pane_pid: 2391033
socket_path: /tmp/tmux-1000/lofa
└── session_name: 2 | server_pid: 2391032 | pane_pid: 2393553