Skip to content

Commit

Permalink
Use systemd.timer instead of cron
Browse files Browse the repository at this point in the history
  • Loading branch information
wagdav committed Oct 31, 2023
1 parent e556081 commit ccb433a
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions modules/push-notifications.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ config, ... }:
{ config, pkgs, ... }:

{
services.ntfy-sh = {
Expand All @@ -19,10 +19,24 @@

users.groups."ntfy" = { };

services.cron = {
enable = true;
systemCronJobs = [
"0 9,12,22 * * * ntfy . ${../scripts/push-room-humidity.sh} >> /tmp/cron-ntfy.log 2>&1"
];
systemd.services."send-room-humidity" = {
path = [ pkgs.curl ];
script = ''
set -eu
${../scripts/push-room-humidity.sh}
'';
serviceConfig = {
Type = "oneshot";
User = "ntfy";
};
};

systemd.timers."send-room-humidity" = {
wantedBy = [ "timers.target" ];
after = [ "network-online.target" ];
timerConfig = {
OnCalendar = [ "*-*-* 8:00" "*-*-* 22:00" ];
Unit = "send-room-humidity.service";
};
};
}

0 comments on commit ccb433a

Please sign in to comment.