MATLAB: What are the LM_LICENSE_FILE and MLM_LICENSE_FILE environment variables and how to set or check for them

MATLAB

What are the LM_LICENSE_FILE and MLM_LICENSE_FILE environment variables, what the differences are between them, and how I set or check for them?

Best Answer

Beginning with MATLAB 6.0 (R12), MLM_LICENSE_FILE can be set to make sure MATLAB is using a specific license file (or server(s) for network licenses). LM_LICENSE_FILE environment variable can also be set to do this, but any FLEXlm application will then use it. MLM_LICENSE_FILE is specific to the MATLAB vendor daemon, MLM, and will not be recognized by other FLEXlm applications.
Note: MATLAB may still read the LM_LICENSE_FILE variable if it is set, before it reads MLM_LICENSE_FILE. One of these variables must be set for clients of a redundant server triad to function properly.
How you find or set these environment variables depends on your Operating System:
Windows
1. Open the System Properties window by pressing the Windows key and “R”. This will open the Run window. Type the following Run command:
SystemPropertiesAdvanced
Then hit enter.
2. Next click the Environment Variables button near the bottom.
3. Under the User variables and System variables, check for a LM_LICENSE_FILE and MLM_LICENSE_FILE variable.
4. Go to New to make one of these variables (this can be set under user or system, depending on the desired usage). The variable name will be:
MLM_LICENSE_FILE
and the value will either be the full path to the license file or port@host, for example:
C:\Program Files\MATLAB\R2009a\licenses\license.dat
or
If you are using a redundant server triad, use commas to separate the servers, for example:
1711@server1,1711@server2,1711@server3
Linux/Unix/Mac OS X 10.9 and below
This can be done in the shell using the setenv or export command depending on the shell. You can either type the command in a shell session (which will make it only last for the session) or you can add it to the appropriate file in your home directory (or create that file if it doesn't exist):
.cshrc (for c-shell)
.profile or .bashrc (for bash)
The . before the file means this is a hidden file. To edit this file, you will need to open it up in a basic text editor and add the command (depending on your shell):
Examples, on c-shell:
setenv MLM_LICENSE_FILE "/usr/local/MATLAB/licenses/license.dat"
setenv MLM_LICENSE_FILE "1711@server1"
Examples, on bash:
export MLM_LICENSE_FILE=/usr/local/MATLAB/licenses/license.dat
export MLM_LICENSE_FILE=27000@server1,27000@server2,27000@server3
Please refer to your Operating System documention for more information on setting an environment variable.
Mac OS X 10.10 and above
Apple is in the process of depreciating environment variables, so see this article for a workaround if you are on OS X 10.10 "Yosemite" or higher: