Search code examples
linuxcentoscentos7systemd

Systemd service unit file as user


I'm new to the concept of systemd unit files in Centos 7 but need to start up the MATLAB license manager at boot. MATLAB doesn't offer a specific solution on how to do this, and the following seems to work but asks for a password when typing systemctl start license-manager and systemctl stop license-manager. Is that expected?

Note this does need to run as a specific user and not as root.

Here is my /etc/systemd/system/license-manager.servicefile:

[Unit]
Description=MATLAB FlexLM license manager

[Service]
Type=forking
ExecStart=/usr/local/MATLAB/R2016a/etc/lmstart
ExecStop=/usr/local/MATLAB/R2016a/etc/lmdown
KillMode=none
Restart=on-failure
RestartSec=90
User=lmlicenseuser

[Install]
WantedBy=multi-user.target

Solution

  • You can try Crontab

    bash$ crontab -e
    

    then add the following line

    @reboot /usr/local/MATLAB/R201Xx/etc/lmstart
    

    This should resolve your issue.