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 pane a PID is in so I can be sure I am killing stuff I want to kill?
相关问题
- tmux script for fast window switching with fzf-tmu
- TMUX Session Won't Import Python Module
- Find PID of a Process by Name without Using popen(
- How to get stdout and stderr from a tmux session?
- iTerm 2 not honoring key bindings declared in .tmu
相关文章
- How to find the PID of any process in Mac OSX C++
- Tmux: how do I bind function keys to commands?
- OSX - How can I see the TID of all threads from my
- nginx.conf and nginx.pid users and permissions
- Find tmux session that a PID belongs to
- Configure tmux scroll speed
- Get the PID of a process started with nohup via ss
- Alert in tmux when a process completes
Given that
PID
in the below line is the target pid number:The above will identify the pane where the
PID
is running. The output will be two strings. The first number should be the same asPID
and the second one (with a percent sign) is "tmux pane id". Example output:Now, you can use "tmux pane id" to kill the pane without "manually" searching for it:
To answer your question completely, in order to find *tmux session* that a PID belongs to, this command can be used:
Here's another possibly useful "line":
The descriptions for all of the interpolation strings (example
#{pane_pid}
) can be looked up in tmux man page in theFORMATS
section.The following script displays the tree of processes in each window (or pane). It takes list of PIDs as one parameter (one PID per line). Specified processes are underlined. It automatically pipes to
less
unless is a part of some other pipe. Example:tmux-processes.sh
:Details regarding listing
tmux
processes you can find here.To underline lines I use ANSI escape sequences. To show the idea separately, here's a script that displays list of processes and underlines some of them (having PIDs passed as an argument):
Usage:
Details regarding
less
and$(tput sgr0)
can be found here.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)