Info
Content

Debian run program as service

Create name.service text file in /lib/systemd/system/

Example of name.service

[Unit]
Description=Minecraft Server

[Service]
Type=simple
#simple for continuos running service
#forking for programs that run and became a daemon
#oneshot for programs that run and stop
User=erli
#User that run the program
ExecStart=/home/erli/start.sh
#Path to the script with the program to run

[Install]
WantedBy=multi-user.target

Run systemctl daemon-reload

Run systemctl enable name.service

Run systemctl restart name.service

Run systemctl status name.service and check if it's running correctly

 

Example of start.sh

#!/bin/bash

cd /home/erli/
java -jar -Xms2048M -Xmx3328M /home/erli/paper-25.jar

exit 0

start.sh needs to be executable. sudo chmod +x /home/erli/start.sh

No Comments
Back to top