tmux 查找pid所在session

先找到

1
tmux list-panes -a -F "#{pane_pid} #{pane_id}" | grep ^PID

但是发现无法找到,查阅man手册发现pane_pid PID of first process in pane

所以找到tty编号pts/159

1
2
ps aux |  grep 12934 | grep -v grep
me 12934 1.5 0.1 23917648 80292 pts/159 Sl+ Aug19 15:00 python train.py

然后找对应session name

1
2
tmux list-panes -a -F "#{pane_pid} #{pane_tty} sname:#{session_name} widx:#{window_index} pidx:#{pane_index}"  |  grep pts/159
31425 /dev/pts/159 sname:49 widx:3 pidx:1

https://man.cx/tmux

请作者喝一杯咖啡☕️