Find tmux session that a PID belongs to

前端 未结 3 1450
眼角桃花
眼角桃花 2021-02-03 10:16

I am using htop so see what processes are taking up a lot of memory so I can kill them. I have a lot of tmux sessions and lots of similar processes. How can I check which tmux p

3条回答
  •  太阳男子
    2021-02-03 10:42

    The answers above give you the pids of the shells running in the panes, you'll be out of luck if you want to find something running in the shells.

    try:

    https://gist.github.com/nkh/0dfa8bf165a53832a4b5b17ee0d7ab12

    This scrip gives you all the pids as well as the files the processes have opened. I never know in which session, window, pane, attached or not, I have a file open, this helps.

    I haven't tried it on another machine, tell me if you encounter any problem.

    lsof needs to be installed.

    if you just want pids, pstree is useful, you can modity the script to use it (it's already there commented)

提交回复
热议问题