docker root crontab job not executing
Why use cron? Just write a shell script like this:
#!/bin/bashwhile true; do python /opt/com.org.project/main.py >> /opt/com.org.project/var/log/cron.log sleep 60done
Then just set it as entrypoint.
ENTRYPOINT ["/bin/bash", "/loop_main.sh" ]
Where did you use crontab -e
? On the host running docker or in the container itself?
I can't see that you are adding an crontab entry in the dockerfile you provided. I recommend you to add an external crontab file like this:
ADD crontabfile /app/crontabRUN crontab /app/crontabCMD ["cron", "-f"]
The file crontabfile
has to be located next to Dockerfile
.
image_folder||- Dockerfile|- crontabfile
Example content of crontabfile
:
# m h dom mon dow command30 4 * * * /app/myscript.py