Skip to main content

Creating a New Service

If you want an application to be able to run at start up.

Create your service file

nano /etc/systemd/system/<application>.service

Add the following information to the file with updated application info. Depending on the service you might not need specific environment variables or a working directory.

[Unit]
Description=Start <application> service
After=network.target

[Service]
Type=simple
User=<your-user>
WorkingDirectory=<path/to/directory>
Environment="FOO=foo"
ExecStart=</path/to/>binary
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target

After saving your entry you can run the following commands

sudo systemctl daemon-reload
sudo systemctl enable <application>.service
sudo systemctl start <application>.service
sudo systemctl status <application>.service

Further Reading

https://www.baeldung.com/linux/systemd-services-environment-variables