LinuxCommandLibrary

invoke-rc.d

Start, stop, or restart system services

SYNOPSIS

invoke-rc.d SERVICE ACTION [ARGUMENT...] [--quiet]

PARAMETERS

SERVICE
    Service name (e.g., apache2), without path or extension

ACTION
    Action like start, stop, restart, reload, force-reload, status

ARGUMENT...
    Optional arguments passed verbatim to the init script

--quiet
    Suppress all output and error messages

DESCRIPTION

invoke-rc.d is a utility in Debian-based systems designed to invoke /etc/init.d service scripts safely from package maintainer scripts (e.g., postinst, prerm). It prevents unintended service restarts or stops during package operations like upgrades, ensuring system stability.

Before executing the script, it checks for /usr/sbin/policy-rc.d. If present, it calls this policy script with the service name and action; the policy can exit 101 to skip execution or 0 to allow it. This hook lets packages override actions, avoiding conflicts.

On SysV init systems, it runs /etc/init.d/SERVICE ACTION [args]. On systemd systems, it detects native units and delegates to deb-systemd-invoke (which calls systemctl), providing compatibility.

Common actions include start, stop, restart, reload, force-reload, and status. Services disabled via update-rc.d or masked won't start. It's essential for Debian Policy compliance in package scripts.

CAVEATS

Respects disabled services (via update-rc.d or systemd masks); does not force actions. Use only in maintainer scripts for policy compliance, not interactively.

POLICY-RC.D HOOK

/usr/sbin/policy-rc.d SERVICE ACTION: Package-provided script. Exit 0 to proceed, 101 to skip, 102+ for other policy decisions.

EXIT STATUS

Returns the invoked script's exit code, or policy-rc.d's if used. Non-zero indicates failure.

HISTORY

Introduced in Debian Policy 3.5.2 (2001, woody era) to standardize safe service handling in packages. Evolved with systemd support via deb-systemd-invoke in Jessie (2015).

SEE ALSO

service(8), update-rc.d(8), systemctl(1), deb-systemd-invoke(8)

Copied to clipboard