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 |
---|---|
|
Intended for clustered sites that do not want to use a shared cachedir for their component cache. |
|
Execute automatic backups ignoring the set schedule. |
|
Back up a single course to a named location. |
|
Validation that the current database structure matches the |
|
Runs the |
|
Checks and ensures that course modules and sections reference each other correctly. Only run when you experience inconsistencies. |
|
Sometimes users get deleted incorrectly. Only run when you experience inconsistencies. |
|
Script that fixes orphaned question categories. |
|
Installs Moodle (see Chapter 1, Moodle Installation). |
|
Installs Moodle in an empty database. |
|
Handle maintenance mode. Custom messages are stored in |
|
MySQL collation conversion. |
|
Detection of row size problems in MySQL InnoDB tables. |
|
Converts MySQL tables to a different engine. |
|
Clears all system caches. |
|
Resets a user's password, including the admin account. |
|
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.
3.145.174.253