#Assume i have ubuntu, selenium and chrome driver in the image
ADD crontab /etc/cron.d/simple-cron
# Add crontab file in the cron directory
ADD crontab /etc/cron.d/simple-cron
# Add shell script and grant execution rights
RUN wget myjava.jar [From some central repository]
RUN chmod +x /myjava.jar
ADD script.sh /script.sh
RUN chmod 777 /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
ADD run.sh /run.sh
RUN chmod +x /run.sh
CMD ["/run.sh"]
Crontab:
* * * * * root /script.sh
script.sh:
export DISPLAY=:99
cd /
/usr/bin/java -jar myjava.jar
run.sh:
#!/bin/bash
Xvfb :99 -screen 0 1024x768x16 &
cron -f
I am using the above mentioned dockerfile, I have a cron job which run every minute. I don't see the logs getting captured in google cloud console.
I see a similar post which discusses similar problem. But i don't see a solution. Google Container Engine stdout Logs Not Showing Up
I cannot move my cron script to the entry point in my Docker file. Please let me know how to redirect the logs to the google cloud console when running cron jobs.
I ran into the same problem and couldn't find a way to get cron to output anything. As a workaround, you can add > /proc/1/fd/1
to your crontab
entry and the output from your script will be logged. For example:
* * * * * root /script.sh >/proc/1/fd/1 2>&1