docker-images icon indicating copy to clipboard operation
docker-images copied to clipboard

Container cron in /etc/cron.d/glpi does not run GLPI tasks

Open pypetrov opened this issue 3 months ago • 1 comments

Description of the problem:

The GLPI Docker image ships with /etc/cron.d/glpi and the cron daemon installed. However, the cron job never runs inside the container. The file contains:

          • su www-data -s /usr/local/bin/php /var/www/glpi/front/cron.php 2>> /var/log/cron-errors.log 1>> /var/log/cron-output.log

Cron expects the format: user command

Because of the su usage, cron interprets su as the username, which is invalid. As a result, the GLPI scheduled tasks are never executed.

Evidence:

  • Cron daemon is running inside the container (ps aux | grep cron), but /var/log/cron-output.log and /var/log/cron-errors.log remain empty.
  • Timestamps of /var/www/glpi/front/cron.php never change.
  • Verified in GLPI Docker image 11.0.2.

Impact:

  • GLPI internal cron tasks do not run.
  • Kubernetes CronJob workaround works fine, but the internal container cron is misleading and broken.

Suggested fix:

  • Either remove the internal cron from the Docker image, or
  • Fix /etc/cron.d/glpi to the correct format, for example:

pypetrov avatar Nov 17 '25 15:11 pypetrov

The cron file is not the systemwide /etc/crontab file but is installed for the root user. It means that the expected columns are m h dom mon dow command and not m h dom mon dow user command.

See https://github.com/glpi-project/docker-images/blob/d462902ff7f4fb3faec3f97f4c82ff0d7a575bfb/glpi/Dockerfile#L148

I tried locally, with the glpi/glpi:10.0 image:

glpi-local  | 2025-11-18 20:59:01 [@b0cebf18590c]
glpi-local  | Externe #1 : Démarrage Cleanoldagents
glpi-local  | 2025-11-18 21:00:01 [@b0cebf18590c]
glpi-local  | Externe #1 : Rien à lancer

then with the glpi/glpi:11.0 image:

glpi-local  | 2025-11-18 21:02:01 [@0cb2dca65043]
glpi-local  | Externe #1 : Démarrage createinquest
glpi-local  | 2025-11-18 21:02:01 [@0cb2dca65043]
glpi-local  | Externe #2 : Démarrage purgedraftforms
glpi-local  | 2025-11-18 21:02:01 [@0cb2dca65043]
glpi-local  | Externe #3 : Démarrage queuedwebhook
glpi-local  | 2025-11-18 21:03:01 [@0cb2dca65043]
glpi-local  | Externe #1 : Démarrage queuedwebhook
glpi-local  | 2025-11-18 21:04:02 [@0cb2dca65043]
glpi-local  | Externe #1 : Démarrage queuedwebhook

The file access time is indeed unchanged, but it is probably due to something else.

$ docker exec -it -u root glpi-local stat /var/www/glpi/front/cron.php
  File: /var/www/glpi/front/cron.php
  Size: 7137      	Blocks: 16         IO Block: 4096   regular file
Device: 0,53	Inode: 528882      Links: 1
Access: (0644/-rw-r--r--)  Uid: (   33/www-data)   Gid: (   33/www-data)
Access: 2025-11-05 09:31:42.000000000 +0000
Modify: 2025-11-05 09:31:42.000000000 +0000
Change: 2025-11-18 21:00:38.855880904 +0000
 Birth: 2025-11-18 21:00:38.855759084 +0000

The /var/log/cron-* logs in are indeed empty, probably because the execution produces no output, but the internal GLPI cron logs can be found in the /var/glpi/logs/cron.log file.

cedric-anne avatar Nov 18 '25 21:11 cedric-anne

Did you verify that your tasks are defined as CLI and not GLPI

Image

I'm working on a PR that will remove the need of the cron https://github.com/glpi-project/docker-images/pull/243

froozeify avatar Dec 18 '25 13:12 froozeify