Activate license checkout from script/command

14 次查看(过去 30 天)
Is there anyway to enable license checkout from a command instead of via: Help -> Licensing -> Borrow License.
Once enabled with Borrow Product Licenses Automatically a simple script can check out the needed features
featureStr = {'Aerospace_Blockset'; ...
'Aerospace_Toolbox'; ...
'Bioinformatics_Toolbox'; ...
'Communication_Blocks'; ...
'Communication_Toolbox'; ...
'Compiler'};
index = cellfun(@(f) license('checkout', f), availableFeatures);
checkedOutFeatures = availableFeatures(logical(index));
However, there is still the initial manual step (which can be forgotten). This is an issue for long simulation (20h+) and working via VPN since a refresh of VPN connection will result in inability for matlab.exe to periodically validate against the license server and terminate these long simulation.
Being able to add a couple of commands at the start of a configuration.m to initiate a borrow+features is the safest way to ensure contiguous simulation

回答(1 个)

Simar
Simar 2023-10-5
编辑:Simar 2023-10-5
Hi Jonathan,
I understand that you are looking for a way to enable automatic license borrowing via a command or script in MATLAB, rather than manually through the GUI.
Unfortunately, Programmatic borrowing of licenses is limited. The license borrowing process is designed to be initiated manually through the MATLAB interface. This is because borrowing a license is a significant action that can affect other users' ability to use the software, so it is not something that should be done lightly or automatically.
However, one can automate the license checkout process for specific toolboxes using thelicense('checkout', feature) command, as showed in your script. This will ensure that the necessary licenses are checked out before long-running simulations begin.
If MATLAB sessions are being terminated due to VPN disconnections, you might want to consider other solutions. For example, run your MATLAB sessions on a machine that has a direct (non-VPN) connection to the license server. Alternatively, work with your IT Admin to enable uninterrupted VPN settings to avoid undesired disconnects.
Hope it helps!
Best Regards,
Simar

类别

Help CenterFile Exchange 中查找有关 Manage Products 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by