I am trying to run my two python files with cron in docker. I have two files a.py and b.py, which are to be run with cron and specific time period between them.
How to approach this through docker?
I am trying to run my two python files with cron in docker. I have two files a.py and b.py, which are to be run with cron and specific time period between them.
How to approach this through docker?
Here is what I am using. You can refer
FROM ubuntu:latest
# Install cron
RUN apt-get update
RUN apt-get install cron
RUN apt-get install -y python3
RUN apt-get install -y python3-pip
# Add crontab file in the cron directory
ADD crontab /etc/cron.d/simple-cron
# Add shell script and grant execution rights
ADD dir/ /
ADD requirements.txt /
ADD script.sh /script.sh
WORKDIR /
RUN pip3 install -r requirements.txt
RUN chmod +x /script.sh
# Give execution rights on the cron job
RUN chmod 0644 /etc/cron.d/simple-cron
# Create the log file to be able to run tail
RUN touch /var/log/cron.log
# Run the command on container startup
CMD printenv | sed 's/^\(.*\)$/export \1/g' > /env.sh && cron && tail -f /var/log/cron.log