The scheduler works only when something calls it periodically. Each call runs one due task (a multi-step task continues until it is finished). If there is nothing to do, the call ends quickly and uses almost no resources.
All options below are described on the module settings page (Extensions > Extensions > Ka Extensions > Task Scheduler > Edit), with the URL and the command for your store.
How often to call it. The settings page recommends every 10-60 minutes. Call it more often if you have tasks with short periods (for example, every 5 minutes) or many tasks: one call runs one task, so other due tasks wait for the next calls. The automatic installation below uses every 2 minutes.
Option A: automatic cron job installation
If the crontab and wget commands are available on the server and PHP can run them, the settings page shows the cron status and a button:
| Status message | Button |
|---|---|
| WARNING: Cronjob record is not found on the server. | Install |
| WARNING: cronjob record exists but it cannot be confirmed as valid. | Re-install |
| INFO: Cronjob is installed successfully. | Uninstall |
| WARNING: crontab command is not found... / wget command is not found... | no button, use another option |
Install adds this line to the crontab of the web server user (every 2 minutes, with the store admin URL from config.php):
Re-install replaces the line, for example after you changed the run key. Uninstall removes it. These buttons need the modify permission for the module.
Option B: cron job in the hosting panel or crontab
Add a cron job that requests the scheduler URL shown on the settings page:
or with curl:
- Always put the URL in quotes, it contains
&. - The path to
wgetorcurlcan be different on your server. - A multi-step task continues through redirects, so the request may take a while. Do not set a very short timeout.
Option C: PHP from the command line
If PHP can run from the command line, the cron job can call the scheduler script directly. The settings page shows the full command for your store:
- No key is needed: the script works only from the command line.
- Add
--task_id=Nto run only the task with ID N. - The path to
phpcan be different on your server (for example/usr/local/bin/php). Use the same PHP version as the store. - Multi-step tasks run in one process until they are finished.
Option D: external cron service
If your hosting has no cron jobs, use an external service that requests the scheduler URL. The settings page has a link to create a job at EasyCron. A call can take up to 60 seconds, so choose a plan that allows such a timeout. Keep the URL private: it contains the run key.
Check that it works
- The task list shows Last Scheduler Start. It changes after every call. "Never" means the scheduler was never called.
- The log file
ka_scheduler.login the OpenCart logs folder (usuallysystem/storage/logs/) gets a "started" line on every call. - A request with a wrong key shows "Task Scheduler: wrong key." See Troubleshooting.
