Query Available Licenses

To which I now have a good working solution for scenario (B) and pointers towards (A) that might eventually turn into a shell script. We’ll start with the ready to run solution:

First posted April 2005. Updated March 2008.

(B) Quit if there are zero licenses free.

From the ArcInfo Worksation Arc: prompt use the PRODUCT and PRODUCTINFO commands. See below for AML lic-check.aml which uses these to create global variables in the form of .LIC$ARC/INFO .LIC$GRID etc. which might be used like:

Arc: &r lic-check
Arc: ;&if %.lic$arc/info% < 2 &then quit;

Thank you Bob Carr of the USDA Forest Service for telling me about PRODUCT and PRODUCTINFO.

(A) Never steal a license which would otherwise go to a user.

This is better worded as: never use the last license. The problem with the approach used for B is that one has to use a license in order to count them.

Luke Pinner and Mat Boonen, each suggested using the “lmutil lmstat” command (installed in “C:\Program Files\ESRI\License” on Windows). To get a list of all licenses and users, use “lmstat -a -c port@server” but you’ll probably want to narrow it down with other options. The following example lists the arcinfo license in use but there doesn’t seem to be an easy way to query the number free licenses.

# lmutil lmstat -a license.dat -c 27004@ -f arc/info

If you have unix commands avaiable[0] this command will count the number of active ArcInfo users (change ‘v9.0’ to the version you are using):

# lmutil lmstat -a license.dat -f arc/info -c 27004@ | grep -c \(v9.0\)

On my computer the documentation for lmutil is located in C:/Program Files/ESRI/License/arcgis9x/Documentation/License_Manager_Guide/lmrefguide.htm The unix sections are more relevant than the windows ones in the context of scripting.

Graham Lake told me of a unix script which he aquired from a company called DIALOG Information Technology, to whom I sent a message but have not yet recieved a reply. I’ll amend this SUM if/when they do.

[0] Google for ‘Microsoft services for UNIX’, MKS nutcracker, OpenNT , CygWin (free & libre), and others. Google:unix+on+windows

Curiously 75% of the respondents hail from Down Under (2 Aussies, 1 Kiwi).

cheers and thanks for all your help,

— MattWilkie – 21 Mar 2005


Hannes Isaak Reuter adds that there is still an aml solution called reserve.aml at arcscripts: “Did your aml ever crashed, because you didn’t got the license you needed ? This aml will wait to get the needed extension. If there is no extension avaiable at the moment it will wait for a given timeout or for predefined 6 minutes, and try again. Usefull for running jobs overnight….”http://arcscripts.esri.com/details.asp?dbid=10415

Luke Pinner contributed arclicenses.ksh a korn shell script to query licenses via lmutil. You’ll need to edit the #vars section for sure, and #defaults PORT_SERVER for simpler command line usage. To get it to work partially on CygWin bash you need to change lmutil to lmutil.exe (two occurences). This will give you the number of licenses in use but not the total possible. The line at fault is #39, “TOTAL=$4”. This could probably be fixed by installing the cygwin version of the korn shell, pdksh.

UPDATE: with Luke’s help there’s now a bash version too: arclicenses.bsh

Set Python to available license level

…Python assumes that you have an ARCINFO license and chokes if you have anything less. I wrote the following snippet of code to check the licensing level and reset the “Product” to the highest license available on the computer. … — Wayne Sutton on ESRI-L.

import win32com.client
GP = win32com.client.Dispatch("esriGeoprocessing.GPDispatch.1")

# This Block checks which ESRI license is available & sets the product.
# If the installed ARCGIS license is less than ArcInfo the script will fail
# unless the product is reset.
if GP.CheckProduct("ArcInfo") == "Available":
    print "ArcInfo"
elif GP.CheckProduct("ArcEditor") == "Available":
    print "ArcEditor"
elif GP.CheckProduct("ArcView") == "Available":
    print "ArcView"

    print "ArcGis is unavailable on this Computer."

GUI Tools

Also see the ArcUserKill addon “…a GUI front end to the lmutil.exe executable that is run from the command line. The application runs the same commands to assess license usage and to kill hung licenses as you might from the command line manually.”

A similar tool Where have all the licenses gone? seems to be a little more reliable and doesn’t require installation (however this does mean you need to create your own start menu or desktop shortcut).

Restart ArcGIS License Service with 1 click

A solution for hung licenses is to put this batch file, restart-license-service.cmd, in the same directory as lmutil.exe (usually C:\Program Files\ESRI\License\arcexe9x) and set a scheduled task to run it every night (or whatever). You’ll need to change the set arclic_server= line to match your server.


Look in or near https://github.com/maphew/arcplus/tree/master/SysAdmin/licenses

  • arclicenses.bsh – bash version of Luke’s korn script
  • arclicenses.ksh – korn shell script to query licenses via lmutil
  • lic-check.aml – query available ArcGIS licenses from Arc: prompt
  • restart-license-service.cmd – Restart ArcGIS license service with one click

Leave a Reply

Your email address will not be published. Required fields are marked *