CLI crawling
The CLI - JoomSitemap plugin adds a command to Joomla's command line. It runs the same crawl as the Crawler page, rebuilds the index and, if you ask for it, writes the XML sitemap and notifies IndexNow. Schedule it with cron or the Windows Task Scheduler and your sitemap stays current without anyone opening the administrator.
Check the plugin
The package enables the plugin when you install it. Open Components > JoomSitemap > CLI Crawling to see its state:
- CLI Plugin Status: Enabled: ready to use.
- CLI Plugin Status: Disabled: click Enable CLI Plugin, or enable CLI - JoomSitemap in System > Manage > Plugins.
Open the CLI Crawling page once before the first command line crawl. The page stores your site's address, which the command needs to know which site to crawl. You can also give the address with --live-site, see below.
The command
Run it from your Joomla folder:
php cli/joomla.php joomsitemap:crawl-website
| Option | What it does |
|---|---|
--write-sitemap |
Writes the XML sitemap after the crawl, when the index changed |
--notify-indexnow |
Notifies IndexNow after the crawl, when the index changed. Needs the IndexNow plugin with a key and Notify IndexNow? set to Yes |
--debug |
Turns on debugging mode: a detailed log is written and the index is not changed |
--live-site=https://www.example.com |
The address of your site. Use it when the stored address is wrong or missing |
--quiet or -q |
Shows only errors. Useful in cron |
-v |
Shows more output, for example Index did not change |
--help |
Shows the help of the command |
The command crawls your site over HTTP or HTTPS like the browser crawl, so the server that runs it must be able to reach your website's address.
What it does
- Crawls the site from the home page, with the crawler settings from the options.
- Rebuilds the index: adds new pages, updates known ones and removes pages it did not find. See What a crawl changes in the index.
- Rebuilds the Link Check results, when Enable Link Check is saved as Yes in the options.
- With
--write-sitemap, writes the sitemap file. With--notify-indexnow, sends the changed pages to IndexNow. Both only happen when the crawl changed the index. - Prints a summary such as
12 added, 3 deleted, 40 updatedand saves a report.
If another command line crawl is still running, the command warns you. Run only one crawl at a time.
If PHP has a time limit for command line scripts that cannot be raised, the command warns you that the crawl may not finish. Ask your host to remove the limit.
Examples
Crawl and write the sitemap:
php cli/joomla.php joomsitemap:crawl-website --write-sitemap
Crawl, write the sitemap and notify IndexNow:
php cli/joomla.php joomsitemap:crawl-website --write-sitemap --notify-indexnow
Crawl a site whose stored address is missing:
php cli/joomla.php joomsitemap:crawl-website --live-site=https://www.example.com --write-sitemap
Schedule it
Cron on Linux
Find the path of PHP with which php. Then run crontab -e and add a line. This one runs every night at 23:55:
55 23 * * * /usr/bin/php /path/to/joomla/cli/joomla.php joomsitemap:crawl-website --write-sitemap --quiet
Replace /usr/bin/php with your PHP path and /path/to/joomla with your Joomla folder.
Hosting control panel
Most hosts have a cron jobs screen in cPanel, Plesk or their own panel. Choose the PHP command line version that matches your Joomla, enter the command with the full path to cli/joomla.php, and set the execution time limit to 0 or well above 60 seconds.
Windows Task Scheduler
- Open Task Scheduler and click Create Basic Task.
- Choose a schedule, for example daily at 23:55.
- Choose Start a program.
- Program/script: the path to
php.exe, for exampleC:\php\php.exe. - Add arguments (optional):
C:\path\to\joomla\cli\joomla.php joomsitemap:crawl-website --write-sitemap
The report
The CLI Crawling page shows the last command line crawl under Last Periodic Crawl:
- When it started and how long it took, and how many URLs were crawled and changed.
- While a crawl runs: when it started and when it last saved progress. If there was no update for more than 30 minutes, a red message warns that the server may have stopped it.
- Errors, if the crawl had any.
Use the toolbar to see more:
- Show Report: the URLs that were added, deleted and updated.
- Show Output: the console output of the crawl. Long output is shortened to about 1,000 lines.
The page also repeats the commands and the scheduling examples under Help.