The Console - RO CSVI plugin adds the rocsvi:chain command to the Joomla console (cli/joomla.php). It runs a whole chain in one go, without a browser, which makes it the way to run a chain from a cron job.
Preparing the chain
On the chain's edit page, in Chain details:
- Set Enabled to Yes.
- Set Enable frontend/cron to Yes.
- Fill in a Secret key. The command must give the same key, so that only those who know it can run the chain.
- Click Save.
Running the command
From the root folder of the Joomla site:
php cli/joomla.php rocsvi:chain --chain_id=3 --key=yoursecretkey
| Option | Description |
|---|---|
--chain_id |
The ID of the chain, shown in the last column of the chains list. |
--chain_name |
The name of the chain, instead of the ID. Put it between quotes when it contains spaces. |
--chain_alias |
The alias of the chain, instead of the ID. |
--key |
The chain's secret key. Required. |
--force |
Cancel a run of this chain that is still in progress, then start a new one. |
The command prints each step as it starts, for example Step 2 of 4: Products import, and Chain finished at the end. At a wait step it prints when the chain carries on, for example Waiting until 2:06 pm, and the command keeps running until then. When a step fails, the command stops with the error, and the run is recorded as failed in the chain's run history.
The same checks as in the administrator are done before the run starts, see Checks before a run.
From a cron job
To run a chain every night at 2 o'clock:
0 2 * * * php /path/to/your/site/cli/joomla.php rocsvi:chain --chain_alias=nightly-feeds --key=yoursecretkey
Use the PHP command line binary of the version your site runs on. Your host can tell you its path if php alone runs a different version. PHP's time limit doesn't apply on the command line, so a long chain isn't stopped halfway.
When the chain is already running
A chain runs once at a time. When a run of the chain is still in progress, the command doesn't start: it reports that the chain is already running, and since when. This includes a run that was started in the administrator and then paused or stalled.
- To continue that run, use Resume in the chains list. The command line can't continue a run; it always starts a new one.
- To start over, add
--force. The run in progress is cancelled first, with a warning, and the new run starts at the first step.
While the command runs
The chains list shows the run as running, and the chain's edit page shows its progress. Leaving that page doesn't pause the run: the command keeps going until the chain has finished.
To stop it, click Cancel run in the chains list. The command stops after the batch it is working on and reports that the run was cancelled. For an export step, which runs in one go, that is when the export has finished. Stopping the command itself, for example with Ctrl+C, leaves the run unfinished. It is then shown as stalled, and can be resumed in the administrator or cancelled.