Problème exécution tache Cron symfony
... / Problème exécution tache ...
BMPCreated with Sketch.BMPZIPCreated with Sketch.ZIPXLSCreated with Sketch.XLSTXTCreated with Sketch.TXTPPTCreated with Sketch.PPTPNGCreated with Sketch.PNGPDFCreated with Sketch.PDFJPGCreated with Sketch.JPGGIFCreated with Sketch.GIFDOCCreated with Sketch.DOC Error Created with Sketch.
Question

Problème exécution tache Cron symfony

by
system express
Created on 2025-02-17 09:10:16 in Tâches automatiques (cron)

Bonjour,

J'ai une application web en symfony 4, et j'ai besoin de lancer deux commandes symfony en Cron. Pour cette raison j'ai mis en place un fichier bash pour exécuter les commandes et j'ai créé une table dans la base de données pour suivre l'exécution. Malheureusement l'exécution n'est pas réalisé que quand je le lance manuellement.

La configuration du Cron dans l'espace ovh est la suivante :

www/mysite/public/runcmd.sh

Le contenu de mon fichier bash est :

#!/bin/sh
/usr/local/php7.4/bin/php -d display_errors=on /home/myuser/www/mywebsite/bin/console app:update-invoice


/usr/local/php7.4/bin/php -d display_errors=on /home/myuser/www/mywebsite/bin/console app:update-links

Dans le fichier de log voila ce que je trouve :

2025-02-17 07:00:03] ## OVH ## START - 2025-02-17 07:00:03.636284 executing: /usr/local/php7.4/bin/php /homez.1032/myuser/www/mywebsite/public/runcmd.sh
[2025-02-17 07:00:03] /usr/local/php7.4/bin/php -d display_errors=on /home/myuser/www/mywebsite/bin/console app:update-invoice
[2025-02-17 07:00:03] /usr/local/php7.4/bin/php -d display_errors=on /home/myuser/www/mywebsite/bin/console app:update-links
[2025-02-17 07:00:03]
[2025-02-17 07:00:03] ## OVH ## END - 2025-02-17 07:00:03.684399 exitcode: 0

Les permissions accordés au fichier bash sont 755.

Quand je lance le fichier bash manuellement l'exécution passe convenablement.

Merci pour votre support


1 Reply ( Latest reply on 2025-02-17 10:49:46 by
fritz2cat 🇧🇪 🇪🇺
)

Bonjour,

Qui vous dit que chez OVH il y a un exécutable à cet endroit: /usr/local/php7.4/bin/php ?

Je ne connais pas Symfony. Si les deux fichiers à exécuter sont des fichiers php, pourquoi ne pas simplement invoquer leur URL ? A ce moment c'est le PHP de l'environnement web qui le prendrait en charge (mais attention: maximum 165 secondes pour l'exécution)