Created
November 4, 2018 14:20
-
-
Save mark-kubacki/7b62fbe312599c0c95462b33254a8deb to your computer and use it in GitHub Desktop.
systemd timer that runs only if another service is active (running)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Docker garbage collection | |
ConditionACPower=true | |
ConditionDirectoryNotEmpty=/var/lib/docker | |
Requisite=docker.service | |
PartOf=docker.service | |
After=docker.service | |
[Service] | |
Environment=GRACE_PERIOD=1h | |
Type=oneshot | |
ExecStart=/usr/bin/docker system prune --force --filter "until=10m" | |
;ExecStart=/usr/bin/docker volume prune --force | |
ExecStart=/usr/bin/docker image prune -a --force --filter "until=${GRACE_PERIOD}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Docker garbage collection (timer) | |
PartOf=docker.service | |
After=docker.service | |
[Timer] | |
OnStartupSec=1h | |
OnUnitActiveSec=2h | |
AccuracySec=15min | |
[Install] | |
WantedBy=docker.service |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment