Content within Cron Job seems that’s not being executed or there is a problem with saving logs. Let me introduce you to my files:
* * * * * python /bin/wrapper.py > /var/log/somelogfile.txt 2>&1
import time print ("Hello World!") time.sleep(2)
FROM ubuntu:20.04 RUN apt-get update && apt-get install -y cron busybox COPY crontab /opt COPY wrapper.py /bin/wrapper.py RUN crontab /opt/crontab CMD busybox syslogd -C; cron -L 2 -f
But logs (so actually "hello world") are not saved into /var/log/somelogfile.txt
I don’t know if content is executed within Crontab job or the there is problem with log. I would like to have it saved into log file.
FYI, I can run following command directly from the running docker (-it mode in Docker; /bin/bash):
python /bin/wrapper.py > /var/log/somelogfile.txt 2>&1 and file with ‘hello world’ is created.
But not by Cron job.
Source: Docker Questions