Skip to Content
Maintenance

Scheduler and background jobs

Turn on cron so the site removes expired roles, sends mail and cleans up on its own, and check that the jobs actually run.

Some work happens without you: the site removes expired roles and items, cancels unpaid invoices, sends mail and webhooks, and deletes old records. By the end of this page cron will start these jobs every minute, and the admin panel will show when each one ran and how it ended.

You need the "Full access (owner)" permission (admin.boss).

Turn on cron

A single command, php flute cron:run, starts every job. The server has to call it once a minute.

Add the line to your hosting panel's scheduler (cron, "Cron jobs", "Scheduled tasks"), or run crontab -e as the site's user:

* * * * * cd <SITE_DIR> && php flute cron:run >> /dev/null 2>&1

While cron isn't running, the admin panel shows the same line with your site folder already filled in.

If the installer connected to your hosting panel, it may have added the job itself. In that case it said "Background tasks were added too."

You can check the line by hand. Run the command from the site folder as the site's user: it prints every job the schedule reached, then a total.

php flute cron:run
core.outbox: ok
core.retention: ok
core.cache-gc: ok
core.queue: ok
core.grants: ok
core.telegram-updates: ok
core.command-reaper: ok
core.platform-sync: ok
payments.poll: ok
core.broadcasts: ok
rewards.retry: ok
sentinel.expire: ok
sentinel.ext: ok
13 task(s) run, 0 failed.

The list depends on your modules. A second run in the same minute prints 0 task(s) run, 0 failed.: the jobs have done their work and wait for their next time.

Check the jobs

Open AdminScheduler. The table lists every job of the engine and modules, with "Schedule", "Last run", "Duration", "Status" and "Next run".

Scheduler: job table with schedule, status and next run
StatusMeaning
OKthe job finished without errors
Failedthe job crashed, the error text is shown in its row
Runningthe job is running right now
Never runcron hasn't reached it yet

"Run now" in a job's row runs it immediately instead of waiting for its schedule. Use it after changing settings when you want to see the result, for example whether mail goes out.

Background jobs have never run

Cron isn't set up or can't run the command. The same warning reads "Background jobs have not run since …" once cron has been silent for more than five minutes. Add the line from the section above and wait a minute. If the warning stays, php on your hosting may point to another PHP version: replace it with the full path to PHP 8.2 or newer, which your hosting support can tell you.

A job with the "Failed" status writes the details to storage/logs/cron-<date>.log, which you can open on the Log files tab. The "Task “…” failed. See its status and the cron log." notice after "Run now" points to the same place.

Cron mode

While cron isn't running, the site does part of its maintenance during ordinary visitor requests, and some pages take longer to open. Once cron works, the scheduler shows the "Cron already runs the scheduler" hint with a "Turn it on" button. It leads to the "Run background jobs by the server scheduler (cron)" switch in AdminSettingsPlatform, see Background jobs by cron.

With the mode on, mail, cleanup and updates run only on schedule. Without the cron line they don't run at all, so add the line first. The web installer turns the mode on by itself as soon as it sees the first cron run.

Queue

Mail, broadcasts and other deferred work go through a queue. The "Sending e-mail and background work" job works through it on every cron run: up to 25 jobs, for no longer than 20 seconds. That's usually enough.

If you send a lot of mail or it has to go out at once, keep the queue worker running. It runs until it's stopped, so start it under systemd or supervisor. In Docker the queue container already does this.

php flute queue:work

Reference

Next

On this page