LinuxCommandLibrary

systemctl-force-reload

Force service configuration reload

TLDR

View documentation for the original command

$ tldr systemctl try-reload-or-restart
copy

SYNOPSIS

systemctl force-reload [UNIT...]
systemctl force-reload [--all] [--no-block] [--no-pager] [--full] [--plain] [--no-legend] [--no-ask-password] [UNIT...]

PARAMETERS

UNIT...
    One or more unit names to operate on. If omitted, and --all is not specified, systemctl typically acts on all loaded units that support the operation. For force-reload, it's usually applied to specific services.

--all
    When specified, apply the operation to all loaded units that are applicable. This is generally used with caution for force-reload as it could trigger many reloads/restarts.

--no-block
    Do not wait for the operation to finish. If this option is specified, systemctl will return immediately after issuing the command, allowing the operation to proceed in the background.

--no-pager
    Do not pipe output into a pager. This is useful for scripting or when output is expected to be short.

--full
    When showing unit names, show the full unit name (including the type suffix, e.g., .service), even if it is a common suffix.

--plain
    Show output in a plain format, without colors or other terminal formatting.

--no-legend
    Do not show the header line (legend) for status output.

--no-ask-password
    Do not prompt for passwords. This can be useful in automated scripts where password prompts would halt execution.

DESCRIPTION

systemctl force-reload is a systemd command used to instruct one or more services to reload their configuration. This operation is designed to apply new configuration settings without fully stopping and restarting the service, which helps minimize downtime. Internally, force-reload acts as an alias for the reload-or-try-restart command.

When systemctl force-reload is invoked on a unit, systemd first checks if an ExecReload command is defined within the unit's service file. If ExecReload is present, systemd executes this command, which is typically configured to send a specific signal (like SIGHUP for many daemons) or run a script that reloads the service's settings gracefully. If the ExecReload command is not defined, or if the unit is not running, systemd falls back to attempting a try-restart operation. A try-restart will restart the unit only if it is already running. This makes force-reload a robust option for applying changes, as it attempts to reload gracefully first, and only restarts if necessary and if the service is active.

This command is particularly useful for services like web servers (e.g., Nginx, Apache) or logging daemons that can re-read their configuration files on the fly without interrupting ongoing operations. It ensures that changes made to a service's configuration are applied efficiently and with minimal impact on service availability.

CAVEATS

  • Fallback to Restart: If a service unit does not define an ExecReload command, systemctl force-reload will fall back to a try-restart operation. This means the service will be stopped and then started again (if it was running), potentially causing a brief period of downtime. Always check the unit file's ExecReload definition if downtime is critical.
  • Not All Services Support Reloading: Some applications or services are not designed to gracefully reload their configuration. In such cases, even with an ExecReload defined, the operation might be equivalent to a full restart or might not work as expected.
  • Asynchronous Operations: When using the --no-block option, systemctl returns immediately. This means the actual reload operation might still be in progress, and the service's status might not instantly reflect the configuration changes.
  • Privileges: Performing force-reload typically requires root privileges or appropriate permissions via Polkit rules.

<I>DIFFERENCE BETWEEN <CODE>RELOAD</CODE> AND <CODE>FORCE-RELOAD</CODE></I>

The primary distinction lies in their fallback behavior.
systemctl reload UNIT: This command will only perform a reload if an ExecReload command is explicitly defined in the unit file and the unit is active. If ExecReload is not present, or the unit is inactive, reload will simply do nothing and return success.
systemctl force-reload UNIT: This command acts as an alias for reload-or-try-restart. It will attempt to execute ExecReload if defined and the unit is active. If ExecReload is not defined or fails, it will then attempt to try-restart the service (i.e., restart it only if it is currently running). This makes force-reload a more "forgiving" command, as it tries to ensure the new configuration is applied, even if it means restarting.

<I>UNIT FILES AND <CODE>EXECRELOAD</CODE></I>

The behavior of systemctl force-reload is heavily dependent on the service unit file, typically located in /etc/systemd/system/ or /usr/lib/systemd/system/. Within the [Service] section of a unit file, the ExecReload directive specifies the command to execute for reloading the service's configuration.

Example ExecReload entry for an Nginx service:

[Service]
ExecReload=/bin/kill -HUP $MAINPID
This tells systemd to send a SIGHUP signal to the main process of Nginx, which Nginx is programmed to interpret as an instruction to reload its configuration files. If ExecReload is omitted, systemctl force-reload will fall back to attempting a restart.

<I>RETURN CODE</I>

The systemctl force-reload command typically exits with a status code of 0 on success. A non-zero exit code indicates an error, such as an invalid unit name, insufficient permissions, or a failure during the reload or restart process. The specific error code and accompanying messages can help diagnose issues.

HISTORY

The systemctl command is an integral part of systemd, the init system and service manager that has become the default for many major Linux distributions, including Fedora, Debian, Ubuntu, and Red Hat Enterprise Linux, since its initial adoption around 2011-2012. Prior to systemd, service management was primarily handled by SysVinit scripts or Upstart.

While the concept of gracefully reloading a service (often via SIGHUP) existed in the SysVinit era, systemd introduced a more structured and declarative way of defining these operations within unit files. The force-reload command, specifically, was designed to encapsulate the common pattern of attempting a graceful reload first, and falling back to a restart only if necessary and if the service is running, thereby providing a robust and convenient interface for administrators to apply configuration changes with minimal disruption. It reflects systemd's goal of providing powerful, flexible, and reliable service management capabilities.

SEE ALSO

systemctl(1), systemctl reload(8), systemctl restart(8), systemctl reload-or-restart(8), systemctl reload-or-try-restart(8), kill(1), systemd.service(5)

Copied to clipboard