14

Trying to run a cron job in a docker container. HAve a supervisord properly configured
(I see cron -f in the ps -ef and if I kill it it respawns)

crontab file (for testing):
* * * * * echo hi >> /root/test

I tried putting it in /etc/cron.d/crontab /etc/crontab and in /var/spool/cron/crontabs/crontab

Nothing is working - I'm not getting anything in /root/test

Any ideas?

Boaz
  • 4,864
  • 12
  • 50
  • 90
  • You may want to stick a syslog daemon in your container to see if `crond` is logging any errors. You also may need to check your crontab syntax; crontab files in places like `/etc/crontab` require an extra username field (e.g., `* * * * * root echo hi >> /root/test`). – larsks May 29 '15 at 12:49
  • Indeed it was the extra username. Thanks! wanna submit it as an answer? – Boaz May 30 '15 at 10:08
  • Glad it helped. Posted! – larsks May 30 '15 at 16:47

1 Answers1

24

You may want to check your crontab syntax; crontab files in places like /etc/crontab require an extra username field, for example:

* * * * * root echo hi >> /root/test

This is documented (not very prominently) in crontab(5):

Jobs in /etc/cron.d/

The jobs in cron.d and /etc/crontab are system jobs, which are used usually for more than one user, thus, additionally the username is needed....

larsks
  • 277,717
  • 41
  • 399
  • 399