title: Run cron with supervisor and docker
body: <p>I'm stuck on an issue with a legacy Laravel project. It uses supervisor and cron to run the scheduled tasks, but it seems that the cronjobs won't run (and have never run apparently).</p>
  
  <p>This is the Dockerfile:</p>
  
  <pre><code>FROM 704666026001.dkr.ecr.eu-central-1.amazonaws.com/laravel-prod
  
  # Copy project
  COPY . /var/www/html/
  
  # Copy cronjob setup fro laravel scheduler
  COPY docker/cron/cron.txt /etc/docker/cron/cron.txt
  
  # Copy laravel queue worker supervisor conf
  COPY docker/supervisor /etc/docker/supervisor/conf
  
  RUN mkdir -p /var/www/html/storage/framework/cache/data \
      &amp;&amp; /usr/bin/crontab -u www-data /etc/docker/cron/cron.txt \
      &amp;&amp; chown -R www-data:www-data /var/www/html/
  </code></pre>
  
  <p>In the docker/supervisor folder, there a two files:
  One named queue-worker.conf with:</p>
  
  <pre><code>[group:laravel]
  programs=laravel-worker
  priority=30
  
  [program:laravel-worker]
  process_name=%(program_name)s_%(process_num)02d
  command=php /var/www/html/artisan queue:work --sleep=3 --tries=3
  user=www-data
  numprocs=1
  startsecs=10
  autostart=true
  autorestart=true
  stdout_logfile=/dev/stdout
  stdout_logfile_maxbytes=0
  stderr_logfile=/dev/stderr
  stderr_logfile_maxbytes=0
  </code></pre>
  
  <p>And cron.conf with:</p>
  
  <pre><code>[group:cron]
  programs=crond
  priority=40
  
  [program:crond]
  process_name=%(program_name)s
  command=crond -f
  user=www-data
  autostart=true
  autorestart=true
  stdout_logfile=/dev/stdout
  stdout_logfile_maxbytes=0
  stderr_logfile=/dev/stderr
  stderr_logfile_maxbytes=0
  </code></pre>
  
  <p>And the file docker/cron/cron.txt has one line:</p>
  
  <pre><code>* * * * * php /var/www/html/artisan schedule:run &gt;&gt; /dev/null 2&gt;&amp;1
  </code></pre>
  
  <p>The docker image does build without any errors. When i run it locally, this is the output:</p>
  
  <pre><code>2020-06-16 10:21:05,045 INFO Included extra file "/etc/docker/supervisor/conf/cron.conf" during parsing
  2020-06-16 10:21:05,045 INFO Included extra file "/etc/docker/supervisor/conf/nginx.conf" during parsing
  2020-06-16 10:21:05,045 INFO Included extra file "/etc/docker/supervisor/conf/php-fpm.conf" during parsing
  2020-06-16 10:21:05,045 INFO Included extra file "/etc/docker/supervisor/conf/queue-worker.conf" during parsing
  2020-06-16 10:21:05,062 INFO RPC interface 'supervisor' initialized
  2020-06-16 10:21:05,063 INFO supervisord started with pid 1
  2020-06-16 10:21:06,073 INFO spawned: 'nginxd' with pid 9
  2020-06-16 10:21:06,078 INFO spawned: 'php-fpmd' with pid 10
  2020-06-16 10:21:06,084 INFO spawned: 'laravel-worker_00' with pid 11
  2020-06-16 10:21:06,088 INFO spawned: 'crond' with pid 12
  2020/06/16 10:21:06 [notice] 9#9: using the "epoll" event method
  2020/06/16 10:21:06 [notice] 9#9: nginx/1.16.1
  2020/06/16 10:21:06 [notice] 9#9: OS: Linux 4.19.76-linuxkit
  2020/06/16 10:21:06 [notice] 9#9: getrlimit(RLIMIT_NOFILE): 1048576:1048576
  2020/06/16 10:21:06 [notice] 9#9: start worker processes
  2020-06-16 10:21:06,121 INFO success: nginxd entered RUNNING state, process has stayed up for &gt; than 0 seconds (startsecs)
  2020-06-16 10:21:06,121 INFO success: php-fpmd entered RUNNING state, process has stayed up for &gt; than 0 seconds (startsecs)
  2020/06/16 10:21:06 [notice] 9#9: start worker process 13
  2020/06/16 10:21:06 [notice] 9#9: start worker process 14
  2020/06/16 10:21:06 [notice] 9#9: start worker process 15
  2020/06/16 10:21:06 [notice] 9#9: start worker process 16
  2020/06/16 10:21:06 [notice] 9#9: start cache manager process 17
  2020/06/16 10:21:06 [notice] 9#9: start cache loader process 18
  [16-Jun-2020 10:21:06] NOTICE: fpm is running, pid 10
  [16-Jun-2020 10:21:06] NOTICE: ready to handle connections
  2020-06-16 10:21:07,259 INFO success: crond entered RUNNING state, process has stayed up for &gt; than 1 seconds (startsecs)
  2020-06-16 10:21:16,253 INFO success: laravel-worker_00 entered RUNNING state, process has stayed up for &gt; than 10 seconds (startsecs)
  </code></pre>
  
  <p>It does show 'crond entered RUNNING state', but the cronjob isn't run in any way.
  Does anyone have an idea why? Is this setup even valid?</p>
  
  <p>Thanks in advance for the help!</p>