How to administer Joomla from the command line

This article describes how to use Joomla's CLI (command-line interface) applications to do administration tasks from the command line. You can use these application scripts in cron jobs to automate common administration tasks.

About Joomla's CLI applications

Unfortunately, Joomla does not have a complete CLI administration solution like WP-CLI for WordPress or Drush for Drupal. However, Joomla does include some application scripts that you can use to do common administrative tasks from the command line.

Because these applications are PHP scripts, you can run them automatically in cron jobs. For information about how to run PHP scripts from cron jobs, please see this article.

The following sections describe the CLI applications included with Joomla.

Purging expired cache files

You can remove expired cache data by using the garbagecron.php application. By running this application periodically, you can keep the Joomla cache at a manageable size and reduce disk space usage.

To run this application, type the following commands:

cd ~/public_html/cli
php garbagecron.php
If you installed Joomla in a subdirectory, change to that directory instead, and then change to the cli directory.

For more information about this application, please visit https://docs.joomla.org/Purging_expired_cache_files.

Checking for extension updates

You can download extension update information by using the update_cron.php application. By running this application periodically, you can make sure that the Joomla administration interface always has up-to-date information about available extension updates.

To run this application, type the following commands:

cd ~/public_html/cli
php update_cron.php
If you installed Joomla in a subdirectory, change to that directory instead, and then change to the cli directory.

Deleting old files after an update

You can remove old files that remain after an update by using the deletefiles.php application. By running this application periodically, you can help reduce disk space usage and keep your Joomla installation streamlined.

To run this application, type the following commands:

cd ~/public_html/cli
php deletefiles.php
If you installed Joomla in a subdirectory, change to that directory instead, and then change to the cli directory.

Managing Smart Search indexing

You can manage the Smart Search indexing feature by using the finder_indexer.php application.

If you run this application with no arguments, it updates the search index incrementally. Alternatively, if you use the —purge option, it deletes and then rebuilds the entire index.

To run this application, type the following commands:

cd ~/public_html/cli
php finder_indexer.php --purge
If you installed Joomla in a subdirectory, change to that directory instead, and then change to the cli directory.

For more information about this application, please visit https://docs.joomla.org/Setting_up_automatic_Smart_Search_indexing.

Writing your own CLI applications

You can also create your own Joomla CLI applications for custom tasks that you want to automate. To do this, we recommend using the Joomla Framework, an extensible, lightweight framework for PHP applications.

For more information about the Joomla Framework, please visit https://framework.joomla.org.

Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.

We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.