Command Line Interface (CLI)

We have already come across the CLI during the installation chapter when we also dealt with upgrades. However, the CLI has a few more tricks up its sleeve, which we will deal with next.

First of all let us look at the way you call any CLI scripts, which are either located in admin/cli/* or in the sub-folder of plugins that offer a CLI option—for example, auth/ldap/cli. To call a CLI script, follow the following notation:

sudo –u <apache_user> /usr/bin/php admin/cli/<script>.php

Your <apache_user> is usually www-data or apache. Every CLI script has a --help parameter that offers additional information and also describes calling options. The following is a list of some useful CLI commands. For all others commands, have a look in their respective CLI directories. We do not list any parameters here as these are explained well in the --help options.

PHP Script

Purpose

alternative_component_cache

Intended for clustered sites that do not want to use a shared cachedir for their component cache.

automated_backups

Execute automatic backups ignoring the set schedule.

backup

Back up a single course to a named location.

check_database_schema

Validation that the current database structure matches the install.xml file.

cron

Runs the cron command (see Chapter 1, Moodle Installation).

fix_course_sequence

Checks and ensures that course modules and sections reference each other correctly. Only run when you experience inconsistencies.

fix_deleted_users

Sometimes users get deleted incorrectly. Only run when you experience inconsistencies.

fix_orphaned_question_categories

Script that fixes orphaned question categories.

install

Installs Moodle (see Chapter 1, Moodle Installation).

install_database

Installs Moodle in an empty database. config.php must already exist.

maintenance

Handle maintenance mode. Custom messages are stored in climaintenance.html.

mysql_collation

MySQL collation conversion.

mysql_compressed_rows

Detection of row size problems in MySQL InnoDB tables.

mysql_engine

Converts MySQL tables to a different engine.

purge_caches

Clears all system caches.

reset_password

Resets a user's password, including the admin account.

upgrade

Upgrades to a newer version (Chapter 1, Moodle Installation).

Additional CLI scripts on moodle.org might come in useful. Examples are updating user pictures via the command line or restoring courses.

While useful for the few operations that are supported, the CLI provides a relatively restricted set of commands. Moosh, which we will cover next, overcomes this limitation.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.174.253