D
D
Dmitry Isaev2019-04-30 09:33:22
Task Schedulers
Dmitry Isaev, 2019-04-30 09:33:22

Why is crontab not working in docker Laravel?

There is a job in crontab:

* * * * * php /var/www/site.ru/artisan schedule:run >>/dev/null 2>&1

When run with the command
php /var/www/site.ru/artisan schedule:run >>/dev/null 2>&1

Moreover, the task is logged in /var/log/syslog, but does not work in Laravel.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry Isaev, 2019-04-30
@IsaevDimka

it worked with the command on the server itself * * * * * docker exec app_swiftcloud sh -c 'php /var/www/site.ru/artisan schedule:run >>/dev/null 2>&1'

O
OnYourLips, 2019-04-30
@OnYourLips

Because docker is not a virtual machine, but a homogeneous group of processes. There is simply no cron running and no need to want to do it.
Crones and other schedulers must be outside the fpm container.
Roughly speaking, for the simplest case, run docker run --rm imagename php /var/www/site.ru/artisan schedule:run on the host

D
Dmitry, 2019-04-30
@thewind

Most likely because the php command is not found in the docker container.
Try to do whereis php and write the full path to the interpreter, something like /usr/local/bin/php
Alternatively, log errors and cron runs separately by adding the crontab file at the top

exec 1>/var/log/cronlog.log
exec 2>/var/log/cronlog.err

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question