I have a system configuration with a service that is needs to regularly fetch data and update some index:
systemd.services.loogle-updater = {
wants = ["network-online.target"];
after = ["network-online.target"];
startAt = "00/6:00"; # repeat every 6 hours
serviceConfig = {
User = "loogle";
WorkingDirectory = "~";
ExecStart = "${self.packages.${pkgs.system}.loogle-updater}/bin/loogle-updater /home/loogle";
NoNewPrivileges = true;
ProtectSystem = "strict";
PrivateTmp = true;
};
unitConfig = {
StartLimitIntervalSec = "10";
StartLimitBurst = "3";
};
};
This works nice in a running system, but a fresh deployment should run this service once immediately.
What is the NixOSiomatic/systemdic way of saying “this unit should be started every 6 hours, but if it has never run before, it should be started immediately”?
I tried to use Persistent
, hoping that “ran never” counts as “should have run”, using
systemd.timers.loogle-updater = {
wantedBy = [ "timers.target" ];
timerConfig.OnCalendar = "00/6:00"; # repeat every 6 hours
timerConfig.Persistent = true;
};
but it seems that doesn’t work.