On my Ubuntu server I run tmux. When I login on the server itself I get tmux, when I login with SSH I get tmux too.
Right after a reboot logging in on the server starts tmux within seconds and when logging in with SSH it starts within seconds too.
After a few weeks and login attempts both locally and remote, logging in with SSH still starts tmux within seconds while with logging in locally on the server tmux starts slower and slower. I've experienced delays of over 20 minutes before tmux appears.
I don't know what's wrong but somehow it seems to be server related. How can I solve this? There are no errormessages regarding tmux.
2 Answers
For me, that was a problem with the following line in my .zprofile
:
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> /home/gbajson/.zprofile
After a few weeks I had over 700 following lines in .zprofile
, so the starts were slower and slower.
gbajson@misio:~$ grep -c "/home/linuxbrew/.linuxbrew/bin/brew shellenv" .zprofile
715
-
I had a line in /etc/profile.d/ that ended up filling my .bashrc with over 26000 lines! Thanks for this answer! Commented Jul 1, 2023 at 17:54
If you are detaching or doing a hard disconnect (something like closing the terminal emulator) from the session when you are finished and running simply tmux
every time you connect, then you are creating a new session every time. Make sure you use something like tmux a || tmux
when you login/connect.
strace
andvalgrind
on tmux might provide additional insight. Some basic performance stats likevmstat
and friends would help as well. Reproducing with a standard / clean config and the latest stable / latest snapshot version respectively would also help narrow it down. Of course - you may need to speed up the process (ex: automate a bunch of attach / detach operations and see if there's a change in the footprint).