[PROMOÇÃO] Assine com + 30% de desconto ANUAL MENSAL (últimas horas)
Johnny
Criador Johnny 12/12/2023

Tenho um container laravel em que preciso executar schedules mas sempre que o container inicia recebo o seguinte erro no log:

seteuid: Operation not permitted

Starting periodic command scheduler: cron failed!

[12-Dec-2023 13:35:50] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root

[12-Dec-2023 13:35:50] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root

[12-Dec-2023 13:35:50] NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root

[12-Dec-2023 13:35:50] NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root

[12-Dec-2023 13:35:50] NOTICE: fpm is running, pid 13

[12-Dec-2023 13:35:50] NOTICE: ready to handle connections

Criador Johnny 12/12/2023
# set your user name, ex: user=carlos
ARG user=johnny
ARG uid=1000

Fiz a instalação do cron: 

RUN apt-get update && apt-get install -y \
    git \
    ...
    cron
 
# Ajustar as permissões do diretório /var/run
RUN chmod 711 /var/run

# Add Cron job for Laravel Scheduler
RUN echo "* * * * * cd /var/www && php artisan schedule:run >> /dev/null 2>&1" | crontab -
 
# Start the Cron service and PHP-FPM
CMD service cron start && php-fpm
Johnny
Criador Johnny 12/12/2023

tentei instalar o cron no container:

johnny@792fb8fb0cd:/var/www$ apt-get install -y cron

E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)

E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?

johnny@792fb8fb0cd:/var/www$ sudo apt-get update && sudo apt-get install -y cron

bash: sudo: command not found

 

Johnny
Manager Carlos Ferreira 12/12/2023

Olá, Johnny! Tudo bem?

Sugiro outra abordagem, veja o que fiz aqui nessa aula: https://academy.especializati.com.br/aula/rodar-comando-do-laravel-todos-os-dias-com-scheduling

Carlos Ferreira
Sabe a Solução? Ajude a resolver!

Precisa estar logado para conseguir responder a este ticket!

Clique Aqui Para Entrar!