Order emails, download links, expiring stock holds and cart cleanup are background jobs. KahunaCart's worker runs them when Grav's scheduler runs, and the scheduler runs when cron starts it once a minute.
A job queued by a storefront page usually runs straight after that page has loaded. Everything else waits for the scheduler: jobs queued from the admin, such as Mark paid or a resent email, every retry of a failed job, and the regular sweeps. Without the cron line, those never run.
Install the cron line
- From the root of your Grav site, print the line to add:
bin/grav scheduler --install
- Add that line to the crontab of the user your site runs as, with
crontab -eor your hosting control panel's cron screen. It looks like this:
* * * * * cd /path/to/grav;/usr/bin/php bin/grav scheduler 1>> /dev/null 2>&1
- Force one run to prove it works:
bin/grav scheduler --run
Check it is working
bin/grav scheduler --jobs
bin/plugin kahunacart check
--jobs should list kahunacart-jobs. The Scheduler check in check goes green once the worker has finished a run, and fails when the last run is more than ten minutes old.
The scheduler runs, but jobs never do
KahunaCart's worker is started as bin/plugin, which finds PHP through the PATH. Cron's PATH is very short and often has no php in it, so the scheduler itself runs while every job it starts fails. bin/grav scheduler --details shows each job's errors; look for env: php: No such file or directory.
Fix it with a PATH line at the top of the crontab that includes the folder holding your PHP binary:
PATH=/usr/local/bin:/usr/bin:/bin
* * * * * cd /path/to/grav && php bin/grav scheduler 1>> /dev/null 2>&1
Tip
While you set this up, send the output to a log file instead of /dev/null. Discarding it hides every error.