Phoenix Ignited is a proud tech solutions partner of Luxauro.com. View their news and media page here: Luxauro.com

How to Create a Systemd Service File

How to Create a Systemd Service File

This tutorial goes through creating a systemd service file. Simple and to the point. It assumes you have a linux service installed, for which your system can’t find systemd <service_name>.service file for. 

Checking Service Install Directory

First off we need to find which directory our service is installed in for most Linux distros it should be under: /usr/local/bin/.

							
							
					which <service_name> # replace <service_name> with your actual service name				
			

Creating Systemd Service File

Next we will create a systemd service file for our service

							
							
					sudo nano /etc/systemd/system/<service_name>.service # replace <service_name> with your actual service name				
			

and we will enter the following into the file:

							
							
					[Unit]
Description= # Your description here
After=network.target

[Service]
ExecStart=/usr/local/bin/<service_name> # # replace <service_name> with your actual service name
Restart=always
User=nobody
Group=nogroup

[Install]
WantedBy=multi-user.target
				
			

Press CTL+O then ENTER to save the file, CTL+X to exit the nano editor.

Next we will reload the systemd daemon.

							
							
					sudo systemctl daemon-reload
				
			

That’s it! You can start and manage your service now just as you would normally.

							
							
					sudo systemctl start <service_name> # replace <service_name> with your actual service name				
			

Walter Miely is a tech entrepreneur and CEO of Phoenix Ignited Tech You can find him on Linkedin. This material is licensed under the CC BY 4.0 License LEGAL DISCLAIMER: The content provided here is provided AS IS, and part of, or the entirety of this content may be incorrect. Please read the entireLegal Disclaimer here.

Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.