cron job not running inside docker container on ubuntu -
i have simple dockerfile follows
from ubuntu:latest add crontab /etc/cron.d/test-cron run chmod a+x /etc/cron.d/test-cron run touch /var/log/cron.log cmd cron && tail -f /var/log/cron.log and content of crontab file simple as
* * * * * root echo "hello world" >> /var/log/cron.log 2>&1 # empty line when run on local os x machine (with docker-machine running), works fine ("hello world" printed log file every minute). however, when try run on ubuntu machine, cron job not run (empty log file).
here's command use run container
docker build -t crontest . docker run --name cron crontest i not sure why case. wonder if wrong ubuntu box have (wrong time setting?). have tried restart machine no effect. have other docker containers running on ubuntu box , they're running fine.
any suggestion on debug/ fix hugely appreciated.
edit:
after going inside container (docker exec -it cron /bin/bash), can verify cron running there:
root@a2ad451af8d9:/# ps -ef | grep cron root 1 0 0 20:15 ? 00:00:00 /bin/sh -c cron && tail -f /var/log/cron.log root 6 1 0 20:15 ? 00:00:00 cron root 7 1 0 20:15 ? 00:00:00 tail -f /var/log/cron.log root 25 11 0 20:21 ? 00:00:00 grep --color=auto cron
install rsyslog inside container apt-get install rsyslog , launch command rsyslogd before starting cron cron -l15 (maximum logging). watch file /var/log/syslog inside container see cron daemon's own log output. tell if there problem parsing crontab , will, in case, log entry every minute similar below if has registered , trying run job.
cron[16]: (root) cmd (echo "hello world" >> /var/log/cron.log 2>&1)
Comments
Post a Comment