Crouton: cannot get cron to work

Created on 1 Aug 2014  路  8Comments  路  Source: dnschneid/crouton

After setting up a crouton chroot, cron does not seem to work.

What I've done:

  1. setup crouton following steps in README
  2. sudo enter-chroot
  3. crontab -e
  4. added * * * * * echo "hi from cron" >> /home/matt/hiFromCron.txt"
  5. after a few minutes, see no output at either /home/matt within the chroot or at the "real" /home/matt outside of the chroot (I went there and added a matt directory)

ps -A | grep cron returns nothing. It definitely looks like cron is not running.

But doing sudo /etc/init.d/cron start just produces "Rather than invoking init scripts through /etc/init.d, use the service(8) ..."

So I do sudo service cron start and get "Unknown job: cron"

And sudo start cron gives me "start: Unknown job: cron"

I'm not convinced this is a Crouton specific issue, but hoping I can get some pointers on what to try next.

question

Most helpful comment

Thanks, it looks to be sudo cron is all that is needed to get cron started.

All 8 comments

crouton doesn't use upstart, so you need to run crond explicitly, probably from the chroot's /etc/rc.local. Look inside /etc/init/cron for the commands needed to launch crond.

Thanks, it looks to be sudo cron is all that is needed to get cron started.

Cool! Thanks for sharing your findings.

Exactly what I needed. Thanks both y'all.

What is the best way to run scripts inside the chroot at shutdown or reboot, for cleanup, etc.? Thanks!

There's no official mechanism for it at the moment. You may be able to make a script that gets run from rc.local that does nothing but wait for SIGTERM, and then performs your cleanup tasks. unmount-chroot will SIGTERM all child processes if it can't unmount everything, and then SIGKILL five seconds later (so hopefully your cleanup takes less than five seconds :) ).

Hmm. Thanks. Five seconds can be pretty tight for some stuff though.

You could modify unmount-chroot to change that timeout. Otherwise, you'll probably have to try some other approach. Also worth noting is that while there's a system dbus message that gets fired on shutdown, crouton doesn't actually respond to it, so even the SIGTERM approach may not work for the shutdown case...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Taylormsz picture Taylormsz  路  5Comments

Jacquelinemarie picture Jacquelinemarie  路  3Comments

wymby picture wymby  路  6Comments

jvschiavo picture jvschiavo  路  4Comments

El-t0ro picture El-t0ro  路  4Comments