Since the container runs as a non-root user (www-data), traditional cron is not available.
Instead, you can add custom supervisor-managed jobs by mounting configuration files into /etc/supervisor/conf.d/.
- Create a supervisor config file for your job
- Mount it into the container at
/etc/supervisor/conf.d/your-job.conf
The image includes a flexible scheduler script at /opt/glpi/scheduler.sh that supports two scheduling modes:
Runs the command immediately on start, then repeats every N seconds:
/opt/glpi/scheduler.sh --interval 21600 -- php bin/console ldap:synchronize_usersWaits until the specified time, then repeats daily:
/opt/glpi/scheduler.sh --daily 03:00 -- php bin/console ldap:synchronize_users| Option | Description |
|---|---|
--interval <seconds> |
Run immediately, then every N seconds |
--daily <HH:MM> |
Wait until time, then repeat daily |
--name <name> |
Name to display in logs (optional) |
--no-wait-for-db |
Skip database availability check |
Create ldap-sync.conf:
[program:ldap-sync]
command = /opt/glpi/scheduler.sh --interval 21600 --name "LDAP Sync" -- php /var/www/glpi/bin/console ldap:synchronize_users
autorestart = true
stdout_logfile = /dev/stdout
stdout_logfile_maxbytes = 0
stderr_logfile = /dev/stderr
stderr_logfile_maxbytes = 0Mount in docker-compose.yml:
services:
glpi:
image: glpi/glpi
volumes:
- ./ldap-sync.conf:/etc/supervisor/conf.d/ldap-sync.conf:roCreate backup.conf:
[program:daily-backup]
command = /opt/glpi/scheduler.sh --daily 02:00 --name "Daily Backup" -- /opt/glpi/scripts/backup.sh
autorestart = true
stdout_logfile = /dev/stdout
stdout_logfile_maxbytes = 0
stderr_logfile = /dev/stderr
stderr_logfile_maxbytes = 0For complex scheduling needs, you can write your own script:
Create my-custom-job.sh:
#!/bin/bash
while true; do
# Calculate seconds until next 3:00 AM
next_run=$(date -d "tomorrow 03:00" +%s)
now=$(date +%s)
sleep $((next_run - now))
# Or wait for an hour
# sleep 3600
# Your logic here
sh /path/to/your/my-custom-job.sh
doneThen create a supervisor my-custom-job.conf config pointing to your mounted script.