-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?

nonopolarity
  • 3,069
  • 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) –  Apr 08 '20 at 14:10
  • interesting it has to be pgrep -l tmux for it to work. Without the -l it won't show the name – nonopolarity Apr 08 '20 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') –  Apr 08 '20 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 – nonopolarity Apr 08 '20 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 ;-) –  Apr 08 '20 at 15:09
  • Sometimes pgrep will not find the command due to its name having been changed. For example, on my Mint system, pgrep firefox returns nothing, whereas pgrep -f firefox (more or less equivalent to ps -ef | grep firefox) finds all the firefox PIDs. So, depending on the specific command and system, you may have to use pgrep, pgrep -f (or ps -ef | grep), or some more complicated command such as @mosvy suggests above. – jrw32982 Aug 16 '20 at 23:23
  • Is this not a valid Unix / Linux question for it to deserve a "-1" vote? – nonopolarity Aug 22 '20 at 15:45

1 Answers1

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
Stephen Kitt
  • 434,908