How can I stop the MathWorks Service Host from running on startup?

221 views (last 30 days)
How can I stop the MathWorks Service Host from running on startup?

Accepted Answer

Matthew Elmer
Matthew Elmer on 1 Aug 2024
Edited: Matthew Elmer on 1 Aug 2024
This answer that was given by the same person who asked the question is a lie. It's easily disabled.
The first and best option for disabling the MathWorks Service Host is to uninstall Matlab and use a better programming language.
If you are in the unfortunate position of needing to be able to run Matlab code due to its recalcitrance in being purged from our research institutions, then you can at least prevent the process from running on startup. I do not know the precise steps to disable the startup process on Windows, but you can probably find and disable it if you poke around in the startup applications settings. On Fedora 40 linux, you can either remove the entry from startup applications via Gnome Tweaks, or you can open
/home/$USER/.config/autostart/mathworks-service-host.desktop
and comment out the part that comes after the equals sign on the line that starts with Exec=, i.e., change
Exec=/home/$USER/.MathWorks/ServiceHost/-mw_shared_installs/v2024.7.0.6/bin/glnxa64/MathWorksServiceHost service --realm-id companion@prod@production
to
Exec=#/home/$USER/.MathWorks/ServiceHost/-mw_shared_installs/v2024.7.0.6/bin/glnxa64/MathWorksServiceHost service --realm-id companion@prod@production.
The audacity of MathWorks to attempt to tell me what I can and cannot do on my own computer is amusing, but foolish.
  2 Comments
Mike VanHorn
Mike VanHorn on 1 Aug 2024
@Matthew Elmer This is good information, but it is useful only when the user has already run the software once. Is there a way to "pre-comment this out" before the user has run the software? I figure I can pre-create the mathworks-service-host.desktop for newly created accounts, but I don't want to have to touch every account which already exists but hasn't run R2024a yet.
I did a search through the install directory, and I didn't find a "mathworks-service-host.desktop" file that could be modified, which I think means it's either compressed somewhere waiting to be deployed when the application starts or it just creates it from scratch.
I guess what I'll do for now is put the modified "mathworks-service-host.desktop" into the skel files for new accounts, and create a script to run through all the existing home directories.
Thanks!
Mike VanHorn
Mike VanHorn on 1 Aug 2024
Edited: Mike VanHorn on 1 Aug 2024
@Matthew Elmer Further testing shows that while commenting out the line in the "mathworks-service-host.desktop" does keep the service from starting at login, the client still gets started when Matlab runs. So, my method of symlinking $HOME/.MathWorks/ServiceHost to a place in the local /tmp directory is still necessary to work around the incredible slowness associated with the creation of that directory the first time a user runs MATLAB (as the client runs from $HOME/.MathWorks/ServiceHost). For those who aren't paying attention, the Service Host installer puts 1.4GB of files into $HOME/.MathWorks/ServiceHost.
So, anyway, still looking for a way to disable the ServiceHost. But, on the bright side, it seems that the ServiceHost processes do get killed when the user logs out, so at least they aren't running rampant.

Sign in to comment.

More Answers (3)

Mike VanHorn
Mike VanHorn on 1 Aug 2024
Edited: Mike VanHorn on 1 Aug 2024
Also, I can confirm this answer is at least partially false.
I tried removing $HOME/.MathWorks/ServiceHost/wilbur26/v2024.7.0.6/bin/glnxa64/MathWorksServiceHost, and while MATLAB start up was then slow, it did start up, and the licensing was fine. So MathWorksServiceHost seems to be NOT "essential for MATLAB licensing and MATLAB startup". I'm thinking it must only be related the MATLAB Connector.
However, there does, indeed, seem to be no way to disable it, and rather only work around it's slowness.

Dimitrios
Dimitrios on 2 Sep 2024
Hi Matthew,
In order to disable MathWorks Service Host from starting at Operating System login, you can:
Windows: Follow these instructions of Microsoft to toggle off the Mathworks Service Host startup
Linux: Delete this file: ~/.config/autostart/mathworks-service-host.desktop
macOS: Delete this file: ~/Library/LaunchAgents/com.mathworks.mathworksservicehost.agent.plist
If these files are deleted, MathWorks Service Host will honour this choice and will not re-create them. However modifying the files, as suggested in other answers, will not work for very long, as they will be updated when MathWorks Service Host is updated.
Please note that MathWorks Service Host will still run when MATLAB is started, and that MathWorks Service Host is required for the correct functioning of MATLAB R2024a and later.
  10 Comments
M. C Ertem
M. C Ertem on 23 Dec 2025 at 17:02
So, MW wants every single person who does not want this MWSH crap wasting our resources to individually call support to ask how to disable it???
HOW ABOUT MAKING A SUPPORT PAGE SHOWING HOW TO DO THIS???
I will do a cron job that calls KillMWSH.sh containing
killall MathWorksServiceHost
rm -rf ~/.MathWorks/ServiceHost
Conor Burgess
Conor Burgess on 23 Dec 2025 at 18:11
If you are seeing problematic resource usage, please do contact support. MathWorks Service Host resource usage should be minimal and should not have a noticeable impact on your machine's performance.

Sign in to comment.


Michael Jablecki
Michael Jablecki on 13 Nov 2025
Also note that the process which spawns multiprocessing processes no longer inherits priority from the first Matlab process. Before: renice the main process and multiprocessing respects that niceness level assigned to the main Matlab process. Now - nope. This is another concrete example of the Matlab disrespecting the need to use more than just Matlab on Linux compute nodes for those without the luxury of fully-dedicated compute machines.

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Products


Release

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!