0

I have setup a cron inside a docker php:8.1.0-fpm-buster. It's running like expected, but there is no log showing up inside the docker desktop, it's a black screen.

Here is the docker file

FROM php:8.1.0-fpm-buster
ARG ENV

RUN apt-get update && apt-get -y install cron

RUN touch /var/log/cron.log
RUN chmod 777 /var/log/cron.log

COPY ./crontab /etc/cron.d/crontab
RUN chmod 0644 /etc/cron.d/crontab
RUN /usr/bin/crontab /etc/cron.d/crontab

CMD [ "cron", "-f", "-L", "2" ]

What I was expecting inside the logs was something similar to linux logs of cron, like this example:

Jan 20 09:32:01 ns555555 CRON[21051]: (root) CMD (echo 'my command')

I tried differents commands:

  • I added bash -c before the cron command
  • I remove the -L 2

I have also found other stackoverflow posts, but eachtime it's not the same cron:

What am I doing wrong ? Did I install the wrong cron ?

Gregory Boutte
  • 584
  • 6
  • 26

1 Answers1

0

I found out the solution inside this post: How to run a cron job inside a docker container?

I added > /proc/1/fd/1 2>/proc/1/fd/2 after the command, now I have the command output inside the logs

* * * * * root echo hello > /proc/1/fd/1 2>/proc/1/fd/2
Gregory Boutte
  • 584
  • 6
  • 26