In this short post I want to show you how to implement the sage notebook as a service in systemd, running as a non-privileged user (I used a Fedora 20 system here). The service will start the sage notebook server automatically whenever the machine boots. This is very useful if you run sagemath in a VM appliance and do not want to use the graphical login from the VM, but the browser from your VirtualBox host.
# cat /etc/systemd/system/mysage.service
Description=A free open-source mathematics software system
ExecStart=/bin/sh -c '/usr/bin/sage -n interface="" automatic_login=False secure=True' &
Just put the shown file
mysage.service into the directory
/etc/systemd/system/ and correct the username (or remove the user line if you want to run as root, but I think you should avoid that for security reasons).
The above example will run the sage notebook in secure mode. If you don’t need this, then just remove the
secure=True entry from the
After you have finished editing the file, you just need to run
# systemctl enable mysage
# systemctl start mysage
to get started. Have fun!