When should the option RemainAfterExit needs to be set true when creating new systemd services?

Use RemainAfterExit=yes for services, which somehow change state of the system. When you want that state reverted, you just stop the service. Then you can start it again, but not without first stopping it. An example would be service which creates a flag in filesystem to be used by some other application. When started, it creates the flag file, then exits, but the service is considered active by systemd. Then you can stop it and it will remove the flag file.

Use RemainAfterExit=no for services, which do some action, but do not change the state of the system. An example would be a service to cleanup /tmp. You start it, it will do its work and then be inactive (no need to stop it). And you can start it again anytime and it will again do its work (cleanup).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)