.. include:: /shortcuts.rstext .. index:: pair: Administration; CLI .. _cli: Command-line interfaces (CLI) -------------------------------- Command-line interfaces (CLI) allow you to interact with Mahara through the command line or terminal rather than through a graphical interface. That can speed up certain actions or make them easier to execute. .. note:: You can view help information on the individual commands that are available for each script: ``sudo -u www-data php htdocs/admin/cli/[file name of the script].php -h`` |new in Mahara 20.10| Cron job monitor ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Configure when you want to be alerted to failures in the cron job in an external monitoring software. .. seealso:: Refer to the :ref:`'Monitor' ` module in the *Plugin administration*. .. index:: single: CLI; Delete certain groups in bulk single: Groups; Delete groups in bulk via CLI .. _cli_groupbulkdelete: Delete certain groups in bulk ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If you have a large site and deleted a lot of accounts, you may also wish to clean up old groups in an efficient way. You can do the following with the bulk group deletion script: * delete all groups that have no members, e.g. after accounts were deleted; * and delete all groups that have only site administrators as members; * and / or delete only groups associated with a certain institution. Execute the script with the following command. A dry run is made by default so that no data is deleted by accident. ``sudo -u www-data php htdocs/admin/cli/delete_inactive_groups.php`` .. index:: single: CLI; Delete certain accounts in bulk .. _cli_userbulkdelete: Delete certain accounts in bulk ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If you want to delete accounts in bulk from the site without needing to go to the administration screen, especially if you have more than 500 accounts to delete, you can use CLI. This script allows you to do the following: * delete all accounts that have never been logged into, i.e. that were created manually, via CSV file, or an automated process; * and / or delete all accounts that have not been logged in since a certain date; * and / or delete only those accounts from a specific institution; * delete accounts that are members of a specific group. Execute the script with the following command. A dry run is made by default so that no data is deleted by accident. ``sudo -u www-data php htdocs/admin/cli/delete_inactive_users.php`` .. index:: single: CLI; Index sites running Elasticsearch faster .. _cli_elasticsearchindexing: Index sites running Elasticsearch faster ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. note:: **Prerequisite**: Elasticsearch is installed and set up to run on the site. When a large site is indexed or re-indexed so that Elasticsearch can display results, this process can take a very long time because the indexing happens on cron runs. If the batch that was indexed finished before the end of the cron though, there is a lag between the next batch starting up again. The ``fast_index`` CLI script starts the next batch indexing right after the previous one finished. You run the script with the following command: ``sudo -u www-data php admin/cli/fast_index.php`` .. index:: single: CLI; Install and update language packs .. _cli_langpacks: Install and update language packs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Typically, if you want to update a language pack, you need to download the entire language pack manually and place it into the appropriate folder. This is cumbersome, especially when you want to update the language packs during minor point updates. Using CLI, you can speed up the process. **Install or update language packs** for your instance of Mahara by listing the language codes. Example (de = German, fr = French): ``sudo -u www-data php admin/cli/sync_langpacks.php -l=de,fr`` This will make a backup of the existing languages if they exist into the dataroot's ``langpacks_backup`` directory. .. note:: The language codes that are used are the official international ones used for the `Mahara language packs `_. **Don't make backups**: Add the ``-b=false`` flag Example: ``sudo -u www-data php admin/cli/sync_langpacks.php -l=de,fr -b=false`` **Restore a backup**: Use the ``-r=true`` flag Example: ``sudo -u www-data php admin/cli/sync_langpacks.php -l=de,fr -r=true`` This will ignore trying to update the English language as that is set within Mahara itself.