Skip to main content

Cron Jobs

Asynchronous jobs in HumHub are used to run potentially heavy or scheduled tasks such as sending out summary mails, notifications or search index optimization. The following section describes how to setup automatic job execution required to handle such jobs. Since those settings are highly dependent on your server environment we can't assure those setting will work for your. If you have trouble setting up the job scheduling described in this guide, please contact your provider to ask for support.

Overview​

There are two commands which needs to be scheduled:

  • CronJob - cron/run
  • Queue - queue/run

cron/run​

The cron command is used to run scheduled jobs which for example need to be executed hourly or daily. You can manually execute the cron command as follows:

docker compose exec humhub /app/yii cron/run

queue/run​

The queue command is used to run asynchronous jobs which are potentially long running and therefore need to be executed in the background. The queue can either be scheduled as CronJob (see below) or with the help of another job-runner like for example Supervisor or Systemd. Please refer to the Asynchronous Tasks section for more details about queuing and job processing.

The queue command can be executed manually as follows:

docker compose exec humhub /app/yii queue/run

CronJob configuration​

As mentioned before, the CronJob configuration highly depends on your server environment. The following section is meant to help you with the CronJob setup and includes a guide for some common environments.

With the Docker installation the scheduler runs inside the image - you don't need to configure any cron jobs on the host. It is controlled via environment variables:

environment:
- HUMHUB_DOCKER__AUTOSTART_SCHEDULER=true # cron/run (enabled by default)
- HUMHUB_DOCKER__AUTOSTART_WORKER=true # queue/run (enabled by default)

For larger setups you can move the scheduler and workers into dedicated, scalable services - the multi-service compose example sketches possible multi-service setups.

You can find configuration examples for various environments in the "Cron Job Setup" Wiki in our HumHub Community.

Status and Troubleshooting​

In case you encounter any issues with the job execution like unsent notifications or summary mails you can check the job status under Administration -> Information -> Background Jobs. Ideally the Last run time of the CronJob Status should be set and updated regularly. The value Waiting of Queue Status should decrease or be empty, while the Done value increases.

Background Jobs Status

Troubleshooting can be done by checking the usual backend logs under Administration -> Information -> Logging. In addition, the output of the two commands themselves can be examined, which differs between the installation methods:

The scheduler and the queue workers write their output to the container log, which you can follow with:

docker compose logs -f humhub

See Logging in the HumHub Docker repository for the available log targets and formats.