[Nix-dev] How do I get the system crontab to work?

Nathan Bijnens nathan at nathan.gs
Mon Jul 13 11:12:56 CEST 2015


Not directly helping you with cron, but any reason why you are using cron
instead of systemd timers? The functionality is the same, but output is
logged to journald, status is kept and accessible using systemctl.
Just add a startAt definition to your systemd service.

N.

On Sun, Jul 12, 2015 at 10:23 PM Jeffrey David Johnson <jefdaj at gmail.com>
wrote:

> I see here that there are upstream issues with cron as far as setting user
> crontab entries:
>
> http://lists.science.uu.nl/pipermail/nix-dev/2014-September/014120.html
>
> But I'm having trouble setting the system ones as well. I think if they
> didn't work
> at all a lot of other things would fail, so I must be setting something
> wrong. This
> simple test doesn't put any files in /tmp or send any emails:
>
> services.cron = {
>   enable = true;
>   mailto = "jefdaj at gmail.com";
>   systemCronJobs = [
>     "* * * * *  test ls -l / > /tmp/cronout 2>&1"
>     "* * * * *
> /nix/store/wc472nw0kyw0iwgl6352ii5czxd97js2-coreutils-8.23/bin/test
> /nix/store/wc472nw0kyw0iwgl6352ii5czxd97js2-coreutils-8.23/bin/ls -l / >
> /tmp/cronout 2>&1"
>   ];
> };
>
> I've checked that it does get written to /etc/crontab:
>
> SHELL=/nix/store/xlxjcjq3bnbwnzq82irlzwxhmx6fvc2w-bash-4.3-p33/bin/bash
>
> PATH=/nix/store/fpqvi360cimx3h1kxdxfvkyip52d1i8y-system-path/bin:/nix/store/fpqvi360cimx3h1kxdxfvkyip52d1i8y-system-path/sbin
> MAILTO="jefdaj at gmail.com"
>
> NIX_CONF_DIR=/etc/nix
> * * * * * test ls -l / > /tmp/cronout 2>&1
> * * * * *
> /nix/store/wc472nw0kyw0iwgl6352ii5czxd97js2-coreutils-8.23/bin/test
> /nix/store/wc472nw0kyw0iwgl6352ii5czxd97js2-coreutils-8.23/bin/ls -l / >
> /tmp/cronout 2>&1
>
> And that the test and ls binaries are on that PATH. Anything else I should
> try?
> Jeff
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.science.uu.nl/pipermail/nix-dev/attachments/20150713/7b4e3b18/attachment-0001.html 


More information about the nix-dev mailing list