-1

Is it true that there is tmux daemon or server running on a Unix / Linux system? If so, what is its name and how can we use

ps ax | grep -i <the_name> 

to be able to see it running?

7
  • You shouldn't be using ps | grep. Use pgrep. And if you're using Linux (where both pgrep and ps are buggy), use grep directly: grep -H . $(grep -li tmux /proc/[0-9]*/comm) Commented Apr 8, 2020 at 14:10
  • interesting it has to be pgrep -l tmux for it to work. Without the -l it won't show the name Commented Apr 8, 2020 at 14:51
  • That's not very interesting. It's the documented behaviour. pgrep -a tmux will show even more info. Both the process name (comm) and the arguments (cmdline) can be faked by a process. If you want to find all the processes which are running a binary, use lsof. Or grep -H '.*' $(find /proc/[0-9]*/exe -lname /usr/bin/tmux 2>/dev/null -printf '%h/comm\n') Commented Apr 8, 2020 at 14:55
  • that's interesting from the perspective of somebody not familiar with pgrep. Should there be only one perspective in the world? I am wondering why ps ax | grep tmux won't be able to show it, and if I do pgrep -l tmux it showed 14975 for the tmux server, and if I do ps 14975 it showed the process for tmux new, not the server Commented Apr 8, 2020 at 15:07
  • ps | grep won't show it because the tmux server changes it's process name to tmux: server (/proc/PID/comm) NOT its command line arguments (/proc/PID/cmdline) which ps is showing by default. Also, if you read the manpages and test the commands, you will change your perspective to someone's familiar with them ;-) Commented Apr 8, 2020 at 15:09

1 Answer 1

2

If you have a tmux session running (attached or detached), then yes, there’s a tmux server running, and you can see it by looking for a tmux process with no tty. Its “comm” entry will be changed to “tmux: server”:

 $ ps -t- | grep tmux 2109406 ? 00:00:00 tmux: server 

or

 $ pgrep -l tmux 2109406 tmux: server 
1
  • 1
    interesting... this is the first time I see a ps -t-... it works well on Ubuntu but not on macOS Commented Apr 8, 2020 at 14:48

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.