Sysadmin

systemd Service Creation: Auto-Restart & Dependencies

systemd Service Creation: Auto-Restart & Dependencies

To create a systemd service, write a unit file in /etc/systemd/system/app.service with an ExecStart= line, add Restart=on-failure and RestartSec= if you want systemd to restart it after a crash, then run systemctl daemon-reload and systemctl enable --now app. Dependencies go in the [Unit] section: After= sets the order, Requires= or Wants= set whether the other unit is pulled in, and they are not interchangeable.

Everything below was tested in November 2026 on Ubuntu 24.04.5 LTS with systemd 255 (255.4-1ubuntu8.18), running as PID 1 in a privileged container. The outputs are real, shortened where marked with “…”. Along the way I hit several behaviours that most guides get wrong: Restart=on-failure does not restart a service killed with SIGTERM, manual restarts count towards the start limit, systemd-analyze verify exits 0 on a misspelled Restart=, and Requires= does not stop your service when the dependency crashes.

systemd service in 60 seconds

sudo useradd -r -s /usr/sbin/nologin app          # dedicated system user
sudo tee /etc/systemd/system/app.service >/dev/null <<'EOF'
[Unit]
Description=Demo app
After=network-online.target
Wants=network-online.target
StartLimitIntervalSec=60
StartLimitBurst=3

[Service]
Type=exec
User=app
EnvironmentFile=/etc/app.env
ExecStart=/opt/app/app.sh
Restart=on-failure
RestartSec=2

[Install]
WantedBy=multi-user.target
EOF
sudo systemd-analyze verify /etc/systemd/system/app.service   # read the output, not just the exit code
sudo systemctl daemon-reload                                  # after every change to the file
sudo systemctl enable --now app                               # start now and at boot
systemctl status app                                          # state, main PID, last log lines
journalctl -u app -f                                          # follow the logs
systemctl show app -p NRestarts                               # how many automatic restarts so far

If the service ended in failed after too many restarts, sudo systemctl reset-failed app clears the counter so you can start it again.

Where the unit file goes

systemd reads unit files from several directories. The ones that matter for an administrator:

Directory Who writes there Use it for
/usr/lib/systemd/system/ Distribution packages Never edit: a package update overwrites it
/etc/systemd/system/ The administrator Your own services, and drop-ins that override packaged ones
/etc/systemd/system/app.service.d/*.conf systemctl edit Partial overrides, merged on top of the main file
/run/systemd/system/ systemd and generators Runtime units, lost at reboot

A file in /etc/systemd/system/ with the same name as one in /usr/lib/systemd/system/ replaces it entirely. To change a single setting of a packaged service, use a drop-in instead (see the systemctl edit section below): you keep receiving the package’s fixes to everything else.

The unit file, section by section

The test application is a small Bash script that prints its environment and, if CRASH_AFTER is set, exits with code 3 after that many seconds. It stands in for any long-running daemon:

#!/bin/bash
echo "app starting, pid $$, user $(id -un), MODE=${MODE:-unset}"
n=0
while true; do
  sleep 1; n=$((n+1))
  if [ -n "$CRASH_AFTER" ] && [ "$n" -ge "$CRASH_AFTER" ]; then echo "fatal: simulated crash" >&2; exit 3; fi
done

The three sections of the unit file in the box above do different jobs:

  • [Unit]: description, ordering and dependencies (After=, Requires=, Wants=, BindsTo=) and the start rate limit (StartLimitIntervalSec=, StartLimitBurst=).
  • [Service]: how to run the process (Type=, ExecStart=, User=, environment), when to restart it, and the sandboxing options.
  • [Install]: used only by systemctl enable. WantedBy=multi-user.target creates the symlink that starts the service at boot.

After systemctl enable --now app:

Created symlink /etc/systemd/system/multi-user.target.wants/app.service -> /etc/systemd/system/app.service.
* app.service - Demo app
     Loaded: loaded (/etc/systemd/system/app.service; enabled; preset: enabled)
     Active: active (running) since Sun 2026-11-15 08:47:27 UTC; 2s ago
   Main PID: 94 (app.sh)
      Tasks: 2 (limit: 22455)
     Memory: 736.0K ()
…
Nov 15 08:47:27 8ef664ab7da2 systemd[1]: Starting app.service - Demo app...
Nov 15 08:47:27 8ef664ab7da2 systemd[1]: Started app.service - Demo app.
Nov 15 08:47:27 8ef664ab7da2 app.sh[94]: app starting, pid 94, user app, MODE=production

Restart=on-failure: which exits actually trigger a restart

Restart= decides whether systemd restarts the service when its main process ends. The default is no. To see exactly what each value does, I started 25 transient services with systemd-run, one per combination of Restart= value and exit type, each with RestartSec=1, and counted the restarts after 5 seconds:

Restart= exit 0 exit 3 SIGKILL SIGTERM SIGSEGV
no no no no no no
on-success yes no no yes no
on-failure no yes yes no yes
on-abnormal no no yes no yes
always yes yes yes yes yes

The column to look at is SIGTERM. For systemd, a process that dies from SIGHUP, SIGINT, SIGTERM or SIGPIPE has exited cleanly, exactly like exit code 0, as stated in the systemd.service manual. With Restart=on-failure, a kill <pid> by another process, a script, or the application itself shutting down on SIGTERM leaves the service stopped. If your service must come back whatever happens, use Restart=always; if some exit codes mean “intentional stop”, list them in RestartPreventExitStatus=.

The other cases behave as expected: a crash (SIGSEGV), the OOM killer (SIGKILL) and a non-zero exit code are all restarted by on-failure. A systemctl stop never triggers a restart, even with Restart=always.

“Start request repeated too quickly”: StartLimitIntervalSec and StartLimitBurst

Automatic restarts are rate-limited. If a unit is started more than StartLimitBurst= times within StartLimitIntervalSec=, systemd stops trying and leaves it in failed. The defaults, read with systemctl show on a unit that sets nothing:

$ systemctl show db2 -p Restart -p RestartUSec -p StartLimitIntervalUSec -p StartLimitBurst
Restart=no
RestartUSec=100ms
StartLimitIntervalUSec=10s
StartLimitBurst=5

With the default RestartSec of 100 ms, a service that crashes at startup burns its five attempts in well under a second. Always set RestartSec= together with Restart=.

To trigger the limit, I put CRASH_AFTER=1 in /etc/app.env and restarted the unit from the box above (StartLimitBurst=3 in 60 seconds, RestartSec=2):

$ journalctl -u app --no-pager
…
Nov 15 08:47:38 8ef664ab7da2 systemd[1]: Started app.service - Demo app.
Nov 15 08:47:39 8ef664ab7da2 app.sh[130]: fatal: simulated crash
Nov 15 08:47:39 8ef664ab7da2 systemd[1]: app.service: Main process exited, code=exited, status=3/NOTIMPLEMENTED
Nov 15 08:47:39 8ef664ab7da2 systemd[1]: app.service: Failed with result 'exit-code'.
Nov 15 08:47:41 8ef664ab7da2 systemd[1]: app.service: Scheduled restart job, restart counter is at 1.
…
Nov 15 08:47:44 8ef664ab7da2 systemd[1]: app.service: Scheduled restart job, restart counter is at 2.
Nov 15 08:47:44 8ef664ab7da2 systemd[1]: app.service: Start request repeated too quickly.
Nov 15 08:47:44 8ef664ab7da2 systemd[1]: app.service: Failed with result 'exit-code'.
Nov 15 08:47:44 8ef664ab7da2 systemd[1]: Failed to start app.service - Demo app.

$ systemctl show app -p NRestarts -p Result -p ActiveState
Result=exit-code
NRestarts=2
ActiveState=failed

Only two automatic restarts, not three: the manual systemctl restart at 08:47:38 counted as the first start. The same thing happened later in the test, while I was changing the unit and restarting it by hand: three systemctl restart within a minute were enough to get Failed with result 'start-limit-hit' on a service that had not crashed at all. Keep that in mind before setting a very low burst on a unit you deploy often.

Once the limit is hit, a manual start is refused too, until the interval expires or you clear the counter:

$ sudo systemctl start app
Job for app.service failed because the control process exited with error code.
See "systemctl status app.service" and "journalctl -xeu app.service" for details.
$ sudo systemctl reset-failed app
$ sudo systemctl start app && systemctl is-active app
active

The error message talks about a “control process” even though no process was started: the real reason is in the journal, Start request repeated too quickly.

The trap: StartLimitIntervalSec belongs in [Unit]

Many older examples put the rate limit in [Service]. Here is what systemd 255 does with it:

$ systemd-analyze verify /etc/systemd/system/sl.service
/etc/systemd/system/sl.service:4: Unknown key name 'StartLimitIntervalSec' in section 'Service', ignoring.
$ echo $?
0
$ systemctl show sl -p StartLimitIntervalUSec -p StartLimitBurst
StartLimitIntervalUSec=10s
StartLimitBurst=10

StartLimitBurst= is still accepted in [Service] for compatibility, StartLimitIntervalSec= is not: you end up with a burst of 10 over the default 10 seconds, a combination nobody chose. Both options go in [Unit], as documented in systemd.unit. StartLimitIntervalSec=0 disables the limit entirely.

Progressive delay: RestartSteps and RestartMaxDelaySec

Since systemd 254 the delay between restarts can grow on its own, from RestartSec= up to RestartMaxDelaySec= in RestartSteps= steps. It is the right tool for a service that depends on something external (a database, a remote API): it retries quickly at first and then stops hammering. Test with a script that exits with code 3 after one second:

[Unit]
StartLimitIntervalSec=0

[Service]
ExecStart=/opt/t/exit3.sh
Restart=on-failure
RestartSec=1
RestartSteps=4
RestartMaxDelaySec=16
$ journalctl -u backoff -o short-precise | grep "Scheduled restart"
08:55:35.959312 … backoff.service: Scheduled restart job, restart counter is at 1.
08:55:39.209294 … backoff.service: Scheduled restart job, restart counter is at 2.
08:55:44.459913 … backoff.service: Scheduled restart job, restart counter is at 3.
08:55:53.709784 … backoff.service: Scheduled restart job, restart counter is at 4.
08:56:10.961707 … backoff.service: Scheduled restart job, restart counter is at 5.

Subtracting the second the script runs each time, the delays are 2, 4, 8 and 16 seconds: exponential growth capped at RestartMaxDelaySec. Note StartLimitIntervalSec=0: without it the rate limit would stop the cycle before the delay gets long.

Type=simple, exec, notify, oneshot

Type= tells systemd when to consider the service started. It decides when units ordered After= yours begin, and whether systemctl start reports an error.

Type= “Started” when Use it for
simple (default) Immediately after fork, before the binary runs Legacy units; prefer exec
exec After the binary has been executed successfully Most daemons that stay in the foreground
notify When the process sends READY=1 via sd_notify Daemons that need time to initialise (load data, open sockets)
oneshot When the process exits Setup scripts, migrations, tasks run before other services
forking When the parent exits after daemonizing Old daemons that fork into the background; needs PIDFile=

The difference between simple and exec shows up the first time a path is wrong. Two identical units with ExecStart=/opt/app/missing:

### Type=simple
$ sudo systemctl start tsimple; echo "rc=$?"
rc=0
$ systemctl status tsimple
x tsimple.service
     Active: failed (Result: exit-code) since Sun 2026-11-15 08:49:11 UTC; 1s ago
    Process: 746 ExecStart=/opt/app/missing (code=exited, status=203/EXEC)

### Type=exec
$ sudo systemctl start texec; echo "rc=$?"
Job for texec.service failed because the control process exited with error code.
See "systemctl status texec.service" and "journalctl -xeu texec.service" for details.
rc=1

With simple the start command reports success and the unit fails a moment later: an Ansible task or a deploy script would carry on without noticing. Status 203/EXEC always means “the binary could not be executed”: wrong path, missing execute permission, or a script without a shebang.

Type=notify with a script that takes 3 seconds to get ready and then calls systemd-notify --ready --status="accepting connections": systemctl start returned after 3 seconds, and the status shows the text sent by the service:

* nall.service
     Active: active (running) since Sun 2026-11-15 08:49:27 UTC; 58ms ago
   Main PID: 804 (sleep)
     Status: "accepting connections"

Many guides say that systemd-notify called from a shell script requires NotifyAccess=all, because the message comes from a child process. In my test with systemd 255 the version with NotifyAccess=main also started correctly after 3 seconds. On older versions this may differ: if a notify service stays in activating until TimeoutStartSec= (90 seconds by default), NotifyAccess= is the first thing to check.

Type=oneshot with RemainAfterExit=yes stays active (exited) after the process ends, so other units can depend on it. It is also the only type that accepts multiple ExecStart= lines, executed in order:

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/mkdir -p /run/demo
ExecStart=/bin/sh -c "echo prepared > /run/demo/state"

Dependencies: After= vs Requires= vs Wants=

This is where systemd surprises people most often. Ordering and requirement are two separate axes:

  • After=db.service sets only the order: if both units are being started, yours waits for db. It does not start db.
  • Wants=db.service starts db together with yours. If db fails, yours starts anyway.
  • Requires=db.service starts db together with yours. If db fails to start, yours is not started; if db is stopped or restarted with systemctl, yours is too.
  • BindsTo=db.service is like Requires=, but yours also stops when db dies on its own.

I tested all four with a fake db.service (a oneshot that takes 3 seconds). First, Requires= without After=:

### Requires= without After=: started together
08:49:46.871814 … systemd[1]: Started app-noafter.service - app-noafter.
08:49:46.887165 … systemd[1]: Starting db.service - Fake database...

### Requires= + After=: app waits for db
08:49:46.990124 … systemd[1]: Starting db.service - Fake database...
08:49:50.038852 … systemd[1]: Finished db.service - Fake database.
08:49:50.046741 … systemd[1]: Started app-req.service - app-req.

Without After= the application started before the database had even begun. Requires= and Wants= almost always need an After= on the same unit.

Then the behaviour when db stops or fails:

### systemctl stop db
app-req     inactive      # Requires=: stopped with db
app-wants   active        # Wants=: unaffected

### db fails to start
$ sudo systemctl start app-req
A dependency job for app-req.service failed. See 'journalctl -xe' for details.
$ journalctl -u app-req -n 2
… systemd[1]: Dependency failed for app-req.service - app-req.
… systemd[1]: app-req.service: Job app-req.service/start failed with result 'dependency'.
$ sudo systemctl start app-wants; echo "rc=$?"
rc=0

The case most guides leave out: what happens when the dependency’s process dies instead of being stopped with systemctl. I started r2 (Requires=db2) and b2 (BindsTo=db2), then killed db2 with SIGKILL:

$ sudo systemctl kill -s KILL db2
$ systemctl is-active db2 r2 b2
failed
active
inactive

With Requires= the application keeps running against a dead database. Only BindsTo= stops it. Use BindsTo= when your service makes no sense without the other one, and combine it with Restart= on both if you want them to recover together.

network-online.target

After=network.target does not mean the network is up: it only guarantees that, at shutdown, your service stops before the network goes down. To wait for a configured network use After=network-online.target plus Wants=network-online.target, as in the example above. That target waits for a “wait-online” service (systemd-networkd-wait-online or NetworkManager-wait-online) to be enabled; if none is, it is reached immediately. The systemd page on network-online explains when it is worth it: often it is better for the service to handle a network that is not there yet, for example by binding to 0.0.0.0 instead of a specific address.

User= and EnvironmentFile=

Run the service as a dedicated user, created with useradd -r -s /usr/sbin/nologin app. If the user does not exist, the process fails with a specific status code:

… systemd[1]: e3.service: Main process exited, code=exited, status=217/USER

EnvironmentFile= loads variables from a KEY=value file, one per line. Three behaviours, all verified in the container:

  1. A missing file blocks the start: Failed to load environment files: No such file or directory, result resources. With a dash in front, EnvironmentFile=-/etc/app.env, a missing file is ignored.
  2. The file is read by systemd (PID 1, as root) before switching to User=. A file owned by root with mode 600 works even if the service runs as app: in my test the variable reached the process, which was running as app. So keep secrets root:root 600; the service user does not need to read them.
  3. Variables from EnvironmentFile= override those set with Environment=, even if Environment= is in a drop-in loaded later. I put Environment=MODE=staging in an override and the process still printed MODE=production, the value from the file. To change a variable, change it in the file or point to a second file.

A changed environment file takes effect at the next systemctl restart app; it does not need daemon-reload, because it is read every time the service starts.

systemd-analyze verify: what it catches and what it lets through

systemd-analyze verify checks a unit file without loading it. I gave it one with two typos and a non-existent dependency:

$ systemd-analyze verify /etc/systemd/system/broken.service
/etc/systemd/system/broken.service:7: Failed to parse service restart specifier, ignoring: on-falure
/etc/systemd/system/broken.service:8: Unknown key name 'RestartSecs' in section 'Service', ignoring.
broken.service: Failed to create broken.service/start: Unit postgresql.service not found.
$ echo $?
1

Removing the missing dependency, the typos stay but the exit code changes:

$ systemd-analyze verify /etc/systemd/system/broken.service
/etc/systemd/system/broken.service:6: Failed to parse service restart specifier, ignoring: on-falure
/etc/systemd/system/broken.service:7: Unknown key name 'RestartSecs' in section 'Service', ignoring.
$ echo $?
0
$ systemctl show broken -p Restart -p RestartUSec
Restart=no
RestartUSec=100ms

Exit code 0, and the service starts without any automatic restart. A check in a pipeline that looks only at the exit code lets this file through. Treat any output as an error, for example with test -z "$(systemd-analyze verify app.service 2>&1)".

daemon-reload and systemctl restart: when you need which

systemctl restart restarts the process with the configuration systemd already has in memory. If you have edited the unit file, the new values are not read until daemon-reload. I changed RestartSec=2 to 5 and restarted without reloading:

$ sudo systemctl restart app
$ systemctl status app
Warning: The unit file, source configuration file or drop-ins of app.service changed on disk. Run 'systemctl daemon-reload' to reload units.
…
$ systemctl show app -p RestartUSec
RestartUSec=2s
$ sudo systemctl daemon-reload
$ systemctl show app -p RestartUSec
RestartUSec=5s

The rule: after editing a unit file or a drop-in by hand, daemon-reload and then restart. systemctl edit runs the reload for you. A change to the application’s own configuration or to the EnvironmentFile only needs restart.

Overriding a unit with systemctl edit

sudo systemctl edit app opens an editor and saves what you write in /etc/systemd/system/app.service.d/override.conf. Only the text between the two comment lines at the top becomes the drop-in; everything below is the current file, shown for reference and discarded. systemctl edit --full app instead edits a full copy of the unit.

The classic mistake is overriding ExecStart= by simply writing the new line:

$ cat /etc/systemd/system/app.service.d/override.conf
[Service]
ExecStart=/opt/app/app.sh --verbose
$ sudo systemctl restart app
Failed to restart app.service: Unit app.service has a bad unit file setting.
$ journalctl -u app -n 1
… app.service: Service has more than one ExecStart= setting, which is only allowed for Type=oneshot services. Refusing.

In a drop-in, list settings such as ExecStart= add to the existing value. To replace it, first empty it with a blank assignment:

[Service]
ExecStart=
ExecStart=/opt/app/app.sh --verbose

With this version the restart succeeds and systemctl status shows the drop-in under Drop-In: /etc/systemd/system/app.service.d. systemctl cat app prints the main file followed by all the drop-ins, in the order they are applied: it is the quickest way to see the configuration systemd really uses.

Reading the logs with journalctl -u

Everything the service writes to stdout and stderr ends up in the journal, along with systemd’s own messages about the unit:

journalctl -u app -b                  # since the last boot
journalctl -u app --since "-15min"    # last 15 minutes
journalctl -u app -f                  # follow, like tail -f
journalctl -xeu app                   # latest lines with explanations, as suggested by systemctl
journalctl -u app -p err -o cat       # errors only, without the prefix

The last command has a catch. In my test journalctl -u app -p err showed systemd’s messages (Failed to start app.service, the refused ExecStart), but not the fatal: simulated crash line written by the script on stderr. By default stderr is logged at priority info, not err. If the application does not use syslog or sd-journal priorities, filter by text, not by priority. For the full set of filters see 15 essential journalctl commands.

Basic hardening and systemd-analyze security

systemd-analyze security scores the sandboxing of a service from 0 (isolated) to 10 (no restrictions). The unit from the 60-second box, which already runs as a non-root user:

$ systemd-analyze security app.service
  NAME                                    DESCRIPTION                                              EXPOSURE
+ User=/DynamicUser=                      Service runs under a static non-root user identity
- NoNewPrivileges=                        Service processes may acquire new privileges                  0.2
- PrivateDevices=                         Service potentially has access to hardware devices            0.2
- ProtectClock=                           Service may write to the hardware clock or system clock       0.2
…
-> Overall exposure level for app.service: 9.2 UNSAFE :-{

A non-root user alone is not enough. I added this drop-in, /etc/systemd/system/app.service.d/hardening.conf:

[Service]
NoNewPrivileges=yes
ProtectSystem=strict
ProtectHome=yes
PrivateTmp=yes
PrivateDevices=yes
ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectKernelLogs=yes
ProtectControlGroups=yes
ProtectClock=yes
ProtectHostname=yes
RestrictSUIDSGID=yes
RestrictNamespaces=yes
RestrictRealtime=yes
LockPersonality=yes
MemoryDenyWriteExecute=yes
CapabilityBoundingSet=
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX
SystemCallFilter=@system-service
SystemCallArchitectures=native
UMask=0077
StateDirectory=app
$ sudo systemctl daemon-reload && sudo systemctl restart app && systemctl is-active app
active
$ systemd-analyze security app.service | tail -1
-> Overall exposure level for app.service: 1.7 OK :-)
$ ls -ld /var/lib/app
drwxr-xr-x 2 app app 4096 Nov 15 08:55 /var/lib/app

From 9.2 to 1.7, with the service still running. ProtectSystem=strict makes the whole file system read-only for the service; StateDirectory=app creates /var/lib/app, owned by the service user, and leaves it writable. Tested with a transient unit with the same two options:

touch: cannot touch '/etc/x': Read-only file system
wrote /var/lib/app/ok

Add options one at a time on a real application and check the journal after each restart: MemoryDenyWriteExecute=yes breaks JIT runtimes (Java, Node.js, some Python libraries), and RestrictAddressFamilies= without AF_NETLINK breaks programs that read network interfaces. The meaning of each option is in systemd.exec. For the same approach applied to the SSH daemon, see SSH hardening on Linux.

Common errors and how to fix them

Symptom Cause Fix
status=203/EXEC Binary not found, not executable, or script without shebang Absolute path in ExecStart=, chmod +x, #!/bin/bash on the first line
status=217/USER The User= does not exist useradd -r -s /usr/sbin/nologin app
Failed to load environment files, result resources Missing EnvironmentFile Create it, or use EnvironmentFile=-/path if optional
Start request repeated too quickly Too many starts within StartLimitIntervalSec Fix the crash, raise RestartSec=, then systemctl reset-failed app
Failed with result 'start-limit-hit' without a crash Repeated manual restarts systemctl reset-failed app; wait out the interval
more than one ExecStart= setting Drop-in adds an ExecStart instead of replacing it Empty ExecStart= line before the new one
changed on disk. Run 'systemctl daemon-reload' Unit file edited by hand systemctl daemon-reload, then restart
Dependency failed for … A unit in Requires= did not start journalctl -u on the dependency; use Wants= if it is optional
Service not restarted after kill SIGTERM counts as a clean exit for on-failure Restart=always
Restart settings ignored, unit starts anyway Typo in a key or value: only a warning Read the output of systemd-analyze verify

If the service writes its own log files, remember that ProtectSystem=strict makes /var/log read-only: use LogsDirectory=app and configure rotation as described in logrotate on Linux, or write to stdout and let the journal handle it.

Frequently Asked Questions

How do I make a systemd service restart automatically on failure?

Add Restart=on-failure and a RestartSec value such as 5 to the Service section, then run systemctl daemon-reload and restart the service. The service is then restarted after a non-zero exit code, a crash or a kill by SIGKILL, but not after a clean exit or SIGTERM. If it must restart in every case, use Restart=always.

What is the difference between Restart=always and Restart=on-failure?

Restart=always restarts the service whenever its process ends, including exit code 0 and termination by SIGTERM. Restart=on-failure only restarts it on a non-zero exit code, an unclean signal such as SIGKILL or SIGSEGV, a timeout or a watchdog failure. Neither restarts a service stopped with systemctl stop.

How do I fix “Start request repeated too quickly”?

It means the unit was started more times than StartLimitBurst within StartLimitIntervalSec, which default to 5 starts in 10 seconds. Find the cause of the crash in journalctl, raise RestartSec, then run systemctl reset-failed on the unit and start it again. The two options go in the Unit section, and manual restarts count towards the limit too.

Do I need systemctl daemon-reload before systemctl restart?

Only if you changed the unit file or one of its drop-ins. systemctl restart uses the configuration systemd already has in memory, and systemctl status warns that the file changed on disk. A change to the EnvironmentFile or to the application’s own configuration takes effect with a simple restart.

What is the difference between After= and Requires= in systemd?

After sets only the start order and does not start the other unit. Requires starts the other unit and prevents yours from starting if it fails, but does not wait for it unless you also add After. In practice you use them together. Requires does not stop your service if the dependency’s process crashes; BindsTo does.

Share this article:

Written by

Rosario Giordano

Rosario Giordano is a system administrator and IT consultant specializing in cybersecurity and cloud, with over 20 years of experience managing enterprise Linux infrastructures. His areas of expertise include SSH hardening, Kubernetes platforms, PostgreSQL databases, VMware/ Proxmox virtualization, and compliance with NIS2 and ISO 27001 security frameworks