Using systemd to run a simple process and keep it up

Short post about using systemd to run a simple process :)

You'll need a service file.

For the most part systemd services are registered in config files stored in /etc/systemd/system/XXX.service

For example, running a minecraft server would look like this:

# /etc/systemd/system/minecraft-server.service
Description=Minecraft Server

ExecStart=/usr/bin/java -Xmx6G -Xms4G -jar /root/minecraft-server/server.jar nogui


For extra docs on systemd settings , checkout:

Load your service intp systemd

systemctl daemon-reload
systemctl enable minecraft-server
systemctl start minecraft-server

Check logs

To check the logs of your systemd service, you can use systemctl, or us journalctl

systemctl status minecraft-server
journalctl -e -u minecraft-server