How-to create your own systemd service files

By: Published: Jul 3rd, 2013 Category: Linux Tips

Many Linux operating systems, like OpenSuse, Fedora are using Systemd daemon instead of Linux init based daemon (known as systemV). Systemd is meant to provide a better framework for expressing services’ dependencies, allow more work to be done in parallel (concurrently) at system startup, and to reduce shell overhead.

I use a script (I made it a service) which gets executed at system boot, this script/service search for certain conditions like network settings and if they are true it reset them with default configuration. Recently I have created a Fedora18 VM and tried to run this service on it but it failed. As Fedora 18 is Systemd based, I now have to configure the script/service to work with it.

Following are the steps which I have followed to create and configure systemd service file.

Note: Location of the script is /etc/init.d/

  1. Go to systemd directory i.e. /usr/lib/systemd/system/
  2. Create a new file with name “servicename.service“. In my case I have created file named “mycustomscript.service
  3. Add following content in the above file:

    Description=mycustomscript Deamon auditd.service[Service]


  4. Now reload the Systemd Daemon using command “systemctl daemon-reload“. This will notify systemd about new service.

    [root@localhost ~]# systemctl daemon-reload
    [root@localhost ~]#

  5. Test the service you have created by starting it “systemctl start mycustomscript“.

    [root@localhost ~]# systemctl start mycustomscript
    [root@localhost ~]#

  6. Now enable the service “systemctl start mycustomscript

    [root@localhost ~]# systemctl enable mycustomscript
    ln -s ‘/usr/lib/systemd/system/mycustomscript.service’ ‘/etc/systemd/system/’
    [root@localhost ~]#

  7. You can check and verify if the is service properly added in systemd or not using command “systemctl –all | grep mycustomscript

If you see your service in the list, bingo you have successfully created the service.


Milind Koyande loves to work on new technologies specially virtualization and troubleshoot server problems. I’m an avid photographer and love to spend my free time close to nature, trying to capture its glory on my camera.

Tags: , , ,

2 Responses to “How-to create your own systemd service files”

  1. vishal
    on Jul 20th, 2013
    @ 1:44 pm

    Hi Milind..
    Nice post..I like your way to express the all steps in simple and easy to understand. Anybody can easily know these steps and implement it to generate our own system serviced files…keep it up..thanks..!!!

  2. Milind Koyande
    on Jul 21st, 2013
    @ 8:52 am

    Hello Vishal,

    Thanks for the visit and comments.

Leave a Reply

Subscribe to eITWebguru

© 2012 eITWebguru. All Rights Reserved.