2017-12-20 14:37:20 +00:00
[#modifying-existing-systemd-services]
2018-02-26 16:43:59 +00:00
= Modifying existing systemd services
2017-12-20 14:37:20 +00:00
This example shows how to modify an existing service. The files for service modification are stored in a directory within `/etc/systemd/system`. This directory is named after the service. For example, this procedure modifies the `httpd` service.
2020-07-26 18:35:01 +00:00
[discrete]
2020-08-05 14:22:16 +00:00
== Prerequisites
2017-12-20 14:37:20 +00:00
* You are logged in as a user with administrator-level permissions.
2018-02-26 16:43:59 +00:00
* You have a configured `httpd` server running through systemd.
2017-12-20 14:37:20 +00:00
2020-07-26 18:35:01 +00:00
[discrete]
2020-08-05 14:22:16 +00:00
== Procedure
2017-12-20 14:37:20 +00:00
. Create a directory for the service modification in the following format: `[SERVICE NAME].service.d`. For example, the directory for the `httpd.service` modification is `httpd.service.d`:
+
----
2018-01-21 17:04:05 +00:00
# mkdir /etc/systemd/system/httpd.service.d/
2017-12-20 14:37:20 +00:00
----
. Create a configuration file within this directory:
+
----
2018-01-21 17:04:05 +00:00
# vi /etc/systemd/system/httpd.service.d/custom.conf
2017-12-20 14:37:20 +00:00
----
. Add your custom configuration. For example:
+
----
[Service]
Restart=always
RestartSec=30
----
. Save the file.
. Restart the `httpd` service:
+
----
2018-01-21 17:04:05 +00:00
# systemctl restart httpd
2017-12-20 14:37:20 +00:00
----
2020-07-26 18:35:01 +00:00
[discrete]
2020-08-05 14:22:16 +00:00
== Related Information
2017-12-20 14:37:20 +00:00
2018-01-21 17:04:05 +00:00
* See link:#common-service-parameters[Common service parameters] for more information about the parameters used in this procedure.