Crontab Not Starting

I am not sure why, but this does not run even though the cron.service is running fine. I am able to run these commands and they function correctly in shell.

# Crontab (username is a placeholder)
services.cron = {
    enable = true;
    systemCronJobs = [
        "30 10 1-7 * 2 root    . /etc/profile; XDG_RUNTIME_DIR=/run/user/$(id -u username) notify-send 'Testing Sirens' 'Sirens are being tested, do not fret!' -u critical"
        "0 17 * * * root    . /etc/profile; XDG_RUNTIME_DIR=/run/user/$(id -u username) notify-send 'SHUTDOWN OR HIBERNATE' 'Shutdown or hibernate please.' -u critical"
    ];
  };

Probably because it can’t find notify-send and it’s running as root (which presumably won’t notify your user).
I’d personally use a systemd user service+timer, and provide the full path to the necessary binaries via interpolation.

2 Likes