LinuxCommandLibrary

systemctl-try-reload-or-restart

Try reloading or restarting a service

TLDR

Reload or restart a specific unit

$ systemctl try-reload-or-restart [unit]
copy

Reload or restart multiple units
$ systemctl try-reload-or-restart [unit1 unit2 ...]
copy

Reload or restart all units matching a pattern
$ systemctl try-reload-or-restart '[pattern]'
copy

SYNOPSIS

systemctl try-reload-or-restart UNIT...

PARAMETERS

UNIT...
    One or more systemd unit names to operate on. These can be services (e.g., nginx.service, my-app), sockets, devices, mount points, or other systemd unit types. For common service units, the .service suffix can often be omitted.

DESCRIPTION

The systemctl try-reload-or-restart command is a convenient and intelligent way to manage systemd services when configuration changes are applied. Its primary purpose is to minimize downtime by attempting a graceful reload before resorting to a full restart.

When invoked, systemctl first checks if the specified service unit supports and defines an ExecReload command in its configuration. If an ExecReload command is found, systemd attempts to execute it, instructing the running service to re-read its configuration without stopping and starting. This method is generally faster and causes less disruption to active connections or processes.

If the service does not define an ExecReload command, if the reload operation fails, or if systemd determines that a reload is not appropriate, systemctl will then proceed to perform a full restart of the service. A full restart involves stopping the service (ExecStop), then starting it again (ExecStart), which typically results in a brief interruption of service.

This command is particularly useful in automation scripts or for administrators who want to update configurations with the least impact, ensuring that a service only restarts if a reload is not possible or sufficient.

CAVEATS

  • For the reload portion of the command to succeed, the service unit file (e.g., /etc/systemd/system/my-service.service) must explicitly define an ExecReload directive. If ExecReload is not defined, the command will always fall back to a full restart.
  • Even with a successful reload, some configuration changes might only take effect after a full restart, depending on how the application itself handles configuration reloads.
  • Always verify the service status after running this command using systemctl status UNIT to ensure it is running as expected.

CHECKING FOR EXECRELOAD SUPPORT

You can determine if a service explicitly supports a reload operation by inspecting its unit file or querying systemd:
systemctl show your-service.service | grep ExecReload
If this command returns an output containing ExecReload= followed by a command, the service is configured to handle reloads. If it returns nothing, it will always restart.

IMPACT OF DAEMON-RELOAD

Note that try-reload-or-restart does not automatically perform a daemon-reload. If you modify a service's unit file (e.g., .service file), you must run systemctl daemon-reload before running try-reload-or-restart for systemd to recognize the changes in the unit file itself.

HISTORY

The systemctl command is the primary control interface for systemd, the init system that has largely replaced traditional SysVinit and Upstart in most modern Linux distributions since the early 2010s. The try-reload-or-restart verb was introduced as part of systemd's evolution to provide more intelligent and less disruptive service management, reflecting a focus on minimizing service downtime during configuration updates.

SEE ALSO

systemctl(1), systemd.service(5), systemctl reload, systemctl restart, systemctl stop, systemctl start, systemctl status, systemctl daemon-reload

Copied to clipboard