Home

RemainAfterExit

RemainAfterExit is a configuration directive used in systemd service unit files. It controls whether systemd should keep a service in the Active state after the main service process has exited.

When RemainAfterExit is set to yes (or true), the unit remains active even after the process has

Typical use involves tasks that need to be completed during boot or at activation time and must

In practice, RemainAfterExit is most commonly applied to Type=oneshot services. When active after exit, status reports

Caveats include the fact that enabling RemainAfterExit causes the unit to occupy an Active state indefinitely

finished.
When
set
to
no
(the
default),
the
unit
becomes
inactive
once
the
main
process
exits.
This
behavior
is
particularly
relevant
for
oneshot
services,
which
run
a
task
to
completion
and
then
terminate,
but
may
still
be
important
for
other
units
to
observe
or
depend
on.
influence
dependency
ordering.
By
keeping
the
service
active
after
exit,
other
units
that
specify
After=,
Requires=,
or
Wants=
can
reliably
wait
for
the
task
to
finish
before
proceeding.
The
unit
can
still
be
stopped
explicitly
with
systemctl
stop,
which
will
transition
it
to
inactive.
show
Active:
active
(exited)
rather
than
inactive,
reflecting
that
the
task
finished
but
the
unit
remains
enabled
in
a
started
state.
This
can
be
helpful
for
modeling
one-off
initialization
steps
or
bootstrapping
tasks
without
leaving
the
unit
in
a
running
state.
unless
explicitly
stopped,
so
use
it
judiciously
to
avoid
unnecessary
startup
delay
or
complexity
in
dependency
graphs.