quick-docs/modules/ROOT/partialsdelete/2delete-proc_modifying-existing-systemd-services.adoc

53 lines
1.7 KiB
Text

[#modifying-existing-systemd-services]
= Modifying existing systemd services
This example shows how to modify an existing service. Service modification are stored within `/etc/systemd/system`, in a single file or in a subdirectory named after the service. For example, this procedure modifies the `httpd` service.
[discrete]
== Prerequisites
* You are logged in as a user with administrator-level permissions.
* You have a configured `httpd` server running through _systemd_.
[discrete]
== Procedure
. _Systemd_ services can be modified using the `systemctl edit` command.
+
----
# systemctl edit httpd.service
----
+
This creates an override file `/etc/systemd/system/httpd.service.d/override.conf` and opens it in your text editor. Anything you put into this file will be *added* to the existing service file.
. Add your custom configuration. For example:
+
----
[Service]
Restart=always
RestartSec=30
----
+
To replace an option that can be set multiple times, it must cleared first, otherwise the override file will add the option a second time.
+
----
[Service]
ExecStart=
ExecStart=<new command>
----
. Save the file. _Systemd_ automatically loads the new service configuration.
. Restart the `httpd` service:
+
----
# systemctl restart httpd
----
To completely replace (instead of just add to/modify) an existing service file, use `systemctl edit --full`, e.g. `systemctl edit --full httpd.service`. This will create `/etc/systemctl/system/httpd.service`, which will be used instead of the existing service file.
[discrete]
== Related Information
* See link:#common-service-parameters[Common service parameters] for more information about the parameters used in this procedure.