mirror of
https://pagure.io/fedora-docs/quick-docs.git
synced 2024-12-01 07:39:48 +00:00
use systemctl edit to modify units
This commit is contained in:
parent
625e746763
commit
9ded02053a
1 changed files with 15 additions and 9 deletions
|
@ -1,7 +1,7 @@
|
||||||
[#modifying-existing-systemd-services]
|
[#modifying-existing-systemd-services]
|
||||||
= Modifying existing systemd services
|
= Modifying existing systemd services
|
||||||
|
|
||||||
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.
|
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]
|
[discrete]
|
||||||
== Prerequisites
|
== Prerequisites
|
||||||
|
@ -13,17 +13,13 @@ This example shows how to modify an existing service. The files for service modi
|
||||||
[discrete]
|
[discrete]
|
||||||
== Procedure
|
== Procedure
|
||||||
|
|
||||||
. 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`:
|
. _Systemd_ services can be modified using the `systemctl edit` command.
|
||||||
+
|
+
|
||||||
----
|
----
|
||||||
# mkdir /etc/systemd/system/httpd.service.d/
|
# systemctl edit httpd.service
|
||||||
----
|
----
|
||||||
|
|
||||||
. Create a configuration file within this directory:
|
|
||||||
+
|
+
|
||||||
----
|
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.
|
||||||
# vi /etc/systemd/system/httpd.service.d/custom.conf
|
|
||||||
----
|
|
||||||
|
|
||||||
. Add your custom configuration. For example:
|
. Add your custom configuration. For example:
|
||||||
+
|
+
|
||||||
|
@ -32,8 +28,16 @@ This example shows how to modify an existing service. The files for service modi
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=30
|
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.
|
. Save the file. _Systemd_ automatically loads the new service configuration.
|
||||||
|
|
||||||
. Restart the `httpd` service:
|
. Restart the `httpd` service:
|
||||||
+
|
+
|
||||||
|
@ -41,6 +45,8 @@ RestartSec=30
|
||||||
# systemctl restart httpd
|
# 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]
|
[discrete]
|
||||||
== Related Information
|
== Related Information
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue