Dave's Brain

Browse - Programming Tips - How do I make a systemd service?

Date: 2013nov27
OS: Linux

Q.  How do I make a systemd service?

A.  This worked for me.  It might not be the perfect way.

1.  Make a script that starts your sevice.
Call it /usr/local/bin/MYSERVICE_start

2.  Make a so-called unit file in /lib/systemd/system/MYSERVICE.service
Put this stuff in it:

[Unit] Description=Description of My Service After=network.target [Service] ExecStart=/usr/local/bin/MYSERVICE_start Type=simple [Install] WantedBy=multi-user.target
3. Make symbolic link
cd /etc/systemd/system ln -s /lib/systemd/system/MYSERVICE.service MYSERVICE.service
4. Make systemd take notice of it
systemctl daemon-reload
5. Activate the service immediately
systemctl start MYSERVICE
6. Enable the service to be started on bootup
systemctl enable MYSERVICE

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.