[Nix-dev] Setting up crontab as nixos user

Bjørn Forsman bjorn.forsman at gmail.com
Tue Sep 2 21:53:02 CEST 2014


On 1 September 2014 08:10, Damien Cassou <damien.cassou at gmail.com> wrote:
> Hi,
>
> how can nixos users (not the nixos system, but simple users) specify
> cron jobs? If a user writes:
>
> $ crontab -e
>
> then he is presented with a file that has this warning:
>
> DO NOT EDIT THIS FILE - edit the master and reinstall.

I installed NixOS (unstable) on a new machine just a few days ago.
When I ran crontab -e, as a regular, I was presented with an empty
file. What nixos version do you run?

> If the user modifies the file nonetheless, cron will never run the
> added jobs. I tried with:
>
> */1 * * * * date >> /tmp/crontest.txt
>
> and the file crontest.txt never contains any date.

I noticed this too. It turns out that user cron runs with
PATH=/usr/bin:/bin, so "date" cannot be found. There will be some
output on stderr saying that the command cannot be found, but this
output seems to only somewhere if using MAILTO. I hope running system
cron with a (exported) PATH will propagate to user cron. I'll push
if/when I've tested that it works.

> If the user creates its own crontab file and then registers it, it won't work:
>
> $ crontab /tmp/my.cron
> cannot chdir(/var/cron), bailing out.
> /var/cron: Permission denied

Never tried that.

Best regards,
Bjørn Forsman


More information about the nix-dev mailing list