systemd Service Hardening & Timers
Low-friction unit isolation directives and persistent timers that handle missed maintenance windows cleanly.
Hardened Service Baseline
Most single-purpose background workers require access only to their own state directory under /var/lib and nowhere else on the host:
[Service]
DynamicUser=yes
StateDirectory=snapshot-worker
ProtectSystem=strict
ProtectHome=yes
PrivateTmp=yes
NoNewPrivileges=yes
CapabilityBoundingSet=
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
MemoryMax=256M
Validating Timer Syntax & Sandbox Score
systemd-analyze calendar --iterations=3 "*-*-* 03:15:00 UTC"
systemd-analyze security snapshot-worker.service
Adding RandomizedDelaySec=15m and Persistent=true inside the matching .timer file spreads batch jobs evenly across hours while guaranteeing missed runs catch up once after reboot.