Skip to content

Instantly share code, notes, and snippets.

@schlady
Created November 11, 2015 16:07
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save schlady/d7ba3dbfd8f31be87078 to your computer and use it in GitHub Desktop.
Save schlady/d7ba3dbfd8f31be87078 to your computer and use it in GitHub Desktop.
systemd service file for Mathematica network license manager MathLM
[Unit]
Description=Mathematica network license manager
After=network.target
[Service]
ExecStart=/usr/sbin/mathlm -foreground -logfile /var/log/mathlm.log -pwfile /opt/Wolfram/MathLM/mathpass
Restart=always
[Install]
WantedBy=multi-user.target
Alias=mathlm.service
@cinderblock
Copy link

Thanks for this example!

I found the Alias=mathlm.service causes issues with SystemD. I also don't think -logfile is necessary as, by default, it will log to stdout, which can then be handled nicely by SystemD. -pwfile isn't necessary as the defaults from the setup script work fine, but worth keeping in case anyone needs it. I also wanted to use a less privileged user: wolfram.


In case anyone wants a more complete example:

# Create a user `wolfram` for MathLM
sudo useradd --system --home-dir /usr/local/Wolfram --create-home --skel /dev/null --gid daemon --shell /bin/false wolfram
# Run the official installer script. It starts mathlm, which we don't want, so kill it. Default paths are fine.
sudo -u wolfram ./M-UNIX-LM-*.sh \&\& killall mathlm
# Handy way to not worry about SystemD paths
sudo systemctl edit --full --force mathlm.service
# Mark it to start at boot
sudo systemctl enable mathlm
# Start it now, too
sudo systemctl start mathlm
[Unit]
Description=Wolfram Network License Manager MathLM
After=network.target

[Service]
ExecStart=/usr/local/Wolfram/MathLM/mathlm -foreground -localtime
# -pwfile /usr/local/Wolfram/MathLM/mathpass
User=wolfram
Group=daemon
Restart=always

[Install]
WantedBy=multi-user.target

Check status:

systemctl status mathlm
journalctl -u mathlm

@schlady
Copy link
Author

schlady commented Jan 15, 2022

Thx for feedback.
You are right in all points. The logfile option was for legacy behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment