I have a systemd service that is making use of DynamicUser and StateDirectory in the unit file, so the service can be restarted freely without losing data. However sometimes I want to completely clean up any persistent data and start it from a blank state, can I do that with some parameters to the systemctl stop command?
EDIT: I'm looking for an official parameter supported by systemctl that will clear all persistent data, not a way to pass arguments to my script.
Asked
Active
Viewed 1,192 times
1
Qtag
- 105
- 8
-
You can pass arguments to you stop command see [this](https://superuser.com/a/728962/742963) answer – Lorenzo Garuti Jul 20 '18 at 10:21
-
I'm asking exactly _which arguments_ can achieve that effect. – Qtag Jul 20 '18 at 10:28
1 Answers
2
From the manual of systemd.exec:
The directories specified with StateDirectory=, CacheDirectory=, LogsDirectory=, ConfigurationDirectory= are not removed when the unit is stopped.
There is no official argument supported by systemd that clears these directories. You can use a script to do that.
Fanatique
- 4,538
- 1
- 18
- 28