LinuxCommandLibrary

systemctl-try-restart

Restart units only if running

TLDR

Restart unit if running

$ systemctl try-restart [unit]
copy
Restart multiple units if running
$ systemctl try-restart [unit1 unit2 ...]
copy
Restart by pattern if running
$ systemctl try-restart '[pattern]'
copy

SYNOPSIS

systemctl try-restart PATTERN...

DESCRIPTION

systemctl try-restart restarts one or more units only if they are currently running. If a unit is not active, no action is taken.
This is useful for restarting services after configuration changes without accidentally starting services that were intentionally stopped.

ALIASES

This command is also known as `condrestart`.

CAVEATS

Does nothing for inactive units. Unlike `restart`, this won't start a stopped service. For units not currently running, the command succeeds without action.

HISTORY

The try-restart subcommand provides safe restart operations that respect the current service state, avoiding unintended service starts.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community