Hello
I have an installation of Nixos that I am trying to add a Systemd timer to update my dynamic-dns on an hourly basis. Below is what I have gotten so far:
systemd.services = {
dynamic-dns-updater = {
path = [
pkgs.curl
];
script = "curl https://freedns.afraid.org/dynamic/update.php?token";
startAt = "hourly";
};
This seems to work, but there are two things I don’t seem smart enough to be able to figure out on my own.
How do I get this setup to run as a non-root user? Or am I misunderstanding something and this is already running as a non-root user.
How do I add a randomized delay?
Thank you
rnhmjoj
September 8, 2022, 8:02am
2
If you don’t specify a user it will run as root, you need to set:
systemd.services.dynamic-dns-updater = {
serviceConfig.User = "username";
};
Uhm, it seems there is a way add a random delay, but I’ve never used it. Try adding something like this:
systemd.timers.dynamic-dns-updater = {
timerConfig.RandomizedDelaySec = 30;
};
3 Likes
uep
September 8, 2022, 8:50am
3
The randomised delay thing gets used by a number of nixos things, one example that comes to mind is the nix.gc.*
service, and it works there
That worked, below is my final configuration
Thank you for your help
#Dynamic-DNS
users.users.dynamicdns = {
isSystemUser = true;
group = "dynamicdns";
};
users.groups.dynamicdns = {};
systemd.services.dynamic-dns-updater = {
serviceConfig.User = "dynamicdns";
path = [
pkgs.curl
];
script = "curl https://freedns.afraid.org/dynamic/update.php?token";
startAt = "hourly";
};
systemd.timers.dynamic-dns-updater.timerConfig.RandomizedDelaySec = "15m";
Thank you
2 Likes
Mic92
September 9, 2022, 8:07pm
5