Repository navigation
Conversation
…ntainer log Cron in Debian and Ubuntu mails the output of a job and discards it where no mail server runs, so the output of the jobs that docker-cronjob adds was lost. docker-cronjob now begins /etc/cron.d/webdevops-docker with SHELL=/usr/local/bin/docker-cronjob-shell, which runs the command with /bin/sh and sends its output to syslog, from where syslog-ng writes it to the container log. With MAILTO set in the crontab file, the script only runs the command and cron mails the output as before; without syslog-ng, the output stays with cron.
Kanti
added a commit
that referenced
this pull request
Nov 23, 2026
The output of the cron jobs of docker-cronjob changes how cron behaves in Debian and Ubuntu (no mail), so it moves to #667. A new image test checks that without LOG_STDOUT and LOG_STDERR the output of the services stays in the container log.
This was referenced Nov 23, 2026
# Conflicts: # docker/base/ubuntu-22.04/conf/bin/usr-bin/docker-cronjob # docs/environment-variables.md
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Split from #657: the output of cron jobs changes how cron behaves, so it gets a pull request of its own.
Why
Cron in Debian and Ubuntu mails the output of a job. Most containers run no mail server, so cron discards it and logs
(CRON) info (No MTA installed, discarding output). Whatever a job thatdocker-cronjobadds prints, including its errors, is lost. BusyBox crond on Alpine already passes the output on to the container log.What
docker-cronjob: begins/etc/cron.d/webdevops-dockerwithSHELL=/usr/local/bin/docker-cronjob-shell.docker-cronjob-shell(new): cron runs each job of that file asdocker-cronjob-shell -c <command>./bin/sh, as cron would, and sends stdout and stderr to syslog withlogger -t cron-job[<pid>], one message per line and per 1 KiB of a longer line. syslog-ng writes them to the container log, or the file ofLOG_STDOUT, as[SYSLOG] cron-job[<pid>]: <line>.MAILTOset in the crontab file, it only runs the command, and cron mails the output as before.MAILTO="", which turns the mail off, sends the output to syslog.base,base-app, unless enabled), the output stays with cron, as before. For@rebootjobs it waits up to 10 seconds for the socket of syslog-ng if supervisord starts it.docs/customization.md#cron-jobs(where the output goes,MAILTO, crontab files of your own),docs/known-issues.md(crontab files of your own still mail),docs/environment-variables.md(LOG_STDOUT),docs/images/php.md.make generate.Changes in behaviour
docker-cronjobgoes to the container log instead of to cron's mail. Where a mail server runs, as Postfix in the-devimages, the user of the job no longer gets it in its mailbox, unless the crontab setsMAILTO./etc/cron.d, are unchanged.Tests
BaseChecks::testDockerCronjobShellLeavesTheOutputToCronWithMailto: withMAILTO, the script prints the output of the command and keeps its exit code (3).BaseChecks::testDockerCronjobShellSendsTheOutputToSyslog: withoutMAILTO, the output reaches the container log ascron-job[<pid>]: …and the script prints nothing, with exit code 3. In images without syslog-ng, the output stays on stdout.ContainerEnvironmentChecks::testCronJobOutputReachesTheFileFromTheEnvironment: a job fromdocker-cronjob(hook70-image-test-cron.sh) writes a line to stdout and one to stderr; both reach the file ofLOG_STDOUT. Only in the Debian and Ubuntu images that start cron.docker-cronjob-shell.How it was verified
ci/: PHPUnit ofci/(341 tests) and PHPStan pass.php-nginx:8.5,php-nginx:8.5-alpineandbase:ubuntu-22.04, built from the published images with the two scripts copied in: the new tests pass.masterafter those images were built (healthcheck,cli, PHP-FPM logs), not from this change. The CI runs the tests on images built from this branch.php-nginx:8.5with the scripts:docker-cronjob '* * * * * application echo PLAIN-JOB' 'MAILTO=root' '* * * * * application echo MAILTO-JOB': after a minute the container log shows[SYSLOG] cron-job[103]: PLAIN-JOB.(CRON) info (No MTA installed, discarding output), so withMAILTOthe output went to cron's mail as before.