[Buildroot] crontab: can't change directory to '/var/spool/cron/crontabs': No such file or directory

Luca Ceresoli luca at lucaceresoli.net
Fri Jan 29 10:13:33 UTC 2016


Dear Alexey, Peter,

Peter Korsgaard wrote:
>>>>>> "Alexey" == Alexey Brodkin <Alexey.Brodkin at synopsys.com> writes:
>
>   > Hello,
>   > Just noticed this:
>   ------------------> 8-------------------
>   > # crontab -e
>   > crontab: can't change directory to '/var/spool/cron/crontabs': No such file or directory
>   ------------------> 8-------------------
>
>   > Obvious solution is:
>   ------------------> 8-------------------
>   > # mkdir -p /var/spool/cron/crontabs
>   ------------------> 8-------------------
>
>   > But the question is if we want that to be done automatically and if
>   > we do want how (read "where") to do it properly?
>
> Yes, the problem is also how should this work together with a readonly
> rootfs? Our default skeleton has /var/spool as a symlink to /tmp/, so we
> cannot add /var/spool/cron/crontabs at build time (unless we change the
> skeleton).

Yeah, changing the skeleton looks like a clean solution at first, but
it would potentially break existing configurations using /var/spool
with a readonly rootfs, and quietly change the behaviour of those with
a rw rootfs... Not good.

Another option, specific for crond and crontab, would be to change
CONFIG_FEATURE_CROND_DIR in the Busybox config so it points to
non-volatile storage. A candidate might be /var/cron, but according to
hier(7):

  - /var/cron: Reserved for historical reasons.
  - /var/spool/cron: Spooled jobs for cron(8).

A variant on this might be:
  - store crontab files in /var/cron (or wherever in the rootfs)
  - add a boot script that creates a symlink
    /var/spool/cron -> /var/cron
  - _not_ change the Busybox config.

>
> What I have done in the past is simply to do it in an init script,
> E.G. something like:
>
>
> # /var/spool is link to /tmp => crontabs are not persistent over boot
> mkdir -p /var/spool/cron/crontabs
> cp /root/crontab /var/spool/cron/crontabs/root
> start-stop-daemon -S -q -p /var/run/crond.pid --exec /usr/sbin/crond -- -l 9
>
> But that isn't very generic.

And it does not save /var/spool/cron/crontabs/root to /root/crontab
after edits, which is the worst drawback IMHO.

This is a topic we may discuss during the Developer Days next week.

-- 
Luca



More information about the buildroot mailing list