Diferencia entre revisiones de «Administración por línea de comando»

De MoodleDocs
(tidy up)
({{Actualizar}})
Línea 2: Línea 2:
|docpagetitle = Administration via command line
|docpagetitle = Administration via command line
}}
}}
{{Pendiente de traducir}}
{{Pendiente de traducir}}{{Actualizar}}
{{Instalación de Moodle}}
{{Instalación de Moodle}}
==Corriendo ''scripts'' con Interfaz por Línea de Comandos ((''CLI'')==
==Corriendo ''scripts'' con Interfaz por Línea de Comandos ((''CLI'')==

Revisión del 16:18 16 nov 2017

Nota: Esta es una traducción de una página de la documentación en idioma Inglés (Docs), que se considera particularmente importante, y que en su versión original se actualiza frecuentemente. Por ello, se le recomienda que revise la página original en idioma inglés: Administration via command line.

Nota: Pendiente de Traducir. ¡Anímese a traducir esta página!.     ( y otras páginas pendientes)

Esta página necesita actualizarse con la información existente en la documentación vigente/moderna/actualizada en el idioma inglés original para Moodle. Se le sugiere al lector que consulte la página original en idioma inglés cuyo enlace está al fondo de esta página. y que, por favor, actualice esta información y quite la plantilla {{Actualizar}} cuando haya terminado.     (otras páginas pendientes de actualizar)


Corriendo scripts con Interfaz por Línea de Comandos ((CLI)

Si Usted tiene acceso de shell a su servidor web, Usted puede encontrar varios scripts CLI (CLI = Command Line Interfase) útiles para la administración de Moodle. Las herramientas de CLI del núcleo de Moodle están localizadas en la carpeta admin/cli/*. Otros plugins proporcionan su funcionalidad CLI mediante scripts en sus propias carpetas cli. Por ejemplo, el script de sincronización enrol_db está localizado en enrol/db/cli/.

Para evitar problemas con el control de acceso, Usted debería de correr los scripts como el propietario del proceso del servidor web. Es especialmente importante para la instalación y actualización por CLI, dado que crean archivos nuevos en el directorio moodledata, y el servidor web tiene que tener acceso de escritura a ellos. En las distribuciones Linux, el usuario que corre el servidor web usualmente es apache o wwrun o httpd o algo similar. Como root Usted probablemente querrá ejecutar los scripts CLI de Moodle de esta manera:

   $ cd /path/to/your/moodle/dir
   $ sudo -u apache /usr/bin/php admin/cli/somescript.php --params

La mayoría de los scripts aceptan el parámetro común --help (o -h) para mostrarle la información completa respecto al uso, por ejemplo:

   $ sudo -u apache /usr/bin/php admin/cli/install.php --help


Nota: Estos scripts están para ser corridos (ejecutados) bajo la identidad del usuario del servidor web. Los ejemplos en esta página usan al usuario apache para ilustración. El valor particular depende de su distribución de Sistema Operativo y de su configuración local. Los valores típicos suelen ser apache, www-data (Ubuntu) o httpd.


¡Nueva característica
en Moodle 3.0!
Si se necesita, la instalación de la BasedeDatos puede saltarse, poblando únicamente config.php.

 $ sudo -u apache /usr/bin/php admin/cli/install.php --skip-database

Actualización por línea de comando

Moodle puede ser actualizado mediante línea de comando. Al igual que con el script de instalación, hay un modo interactivo y otro no-interactivo para actualizar. El script por sí mismo no pone al sitio en modo de mantenimiento, Usted mismo tiene que hacerlo. También, tome nota de que el script no respalda los datos (pero si está leyendo esta página Usted probablemente tenga sus propios scripts para respaldar moodledata y la BasedeDatos ¿o nó?)

   $ sudo -u apache /usr/bin/php admin/cli/upgrade.php

Actualizar mediante línea de comando es una forma muy cómoda de actualizar Moodle si Usted usa Git checkout' del código fuente de Moodle (vea Git para Administradores). Vea el siguiente procedimiento sobre cómo actualizar su sitio a los pocos segundos de la versión más reciente, al mismo tiempo que preserva sus eventuales personalizaciones locales seguidas en el repositorio git:

   $ cd /var/www/sites/moodle/htdocs/
   $ sudo -u apache /usr/bin/php admin/cli/maintenance.php --enable
   $ git pull
   $ sudo -u apache /usr/bin/php admin/cli/upgrade.php
   $ sudo -u apache /usr/bin/php admin/cli/maintenance.php --disable

Instalación por línea de comando

Since version 2.0, Moodle can be installed from the command line. There are two modes of installation. In interactive mode, the install script asks you for all data needed to properly set up new Moodle site. In non-interactive mode, you must provide all required data as the script parameters and then the new site is installed silently. The parameters can be passed in the interactive mode, too. The provided values are then used as the default values during the interactive session.

   $ sudo -u apache /usr/bin/php admin/cli/install.php --lang=cs

Modo de mantenimiento

Para cambiar su sitio hacia Modo de mantenimiento mediante la Interfaz por Línea de Comando, Usted puede usar

   $ sudo -u apache /usr/bin/php admin/cli/maintenance.php --enable

Para desactivar el Modo de mantenimiento, simplemente ejecute el mismo script con --disable parameter.

Este script también creará y quitará el archivo climaintenance.html para el modo "Fuera-de-línea (Offline)".

Modo fuera de línea (Offline)

In some situations, you may want to switch your Moodle site into offline mode so that it is not accessible via the web but you can not stop the web server completely (typically because there are other web pages and applications running there). If a file called climaintenance.html exists in the root folder of moodledata directory, Moodle will automatically display the contents of that file instead of any other page.

   $ cd /var/www/sites/moodle/moodledata/
   $ echo '<h1>Sorry, maintenance in progress</h1>' > climaintenance.html

You can prepare a nice formatted HTML page to inform your users about the server being down and keep in the moodledata directory under a name like climaintenance.off and rename it to the climaintenance.html if needed.

Valores por defecto personalizados del sitio (Custom site defaults)

During the install and upgrade via CLI, Moodle sets the administration variables to the default values. You can use different defaults. See MDL-17850 for details. Shortly, all you need to do is to add a file local/defaults.php into your Moodle installation. The format of the file is like

<?php $defaults['pluginname']['settingname'] = 'settingvalue'; // for plugins $defaults['moodle']['settingname'] = 'settingvalue'; // for core settings

These defaults are used during install, upgrade and are also displayed as defaults at the Site administration pages.

Reiniciar contraseña de usuario

Si Usted perdiera su contraseña de administrador (o si quiere configurar una contraseña para cualquier otro usuario de su sistema Moodle), Usted puede usar el script reset_password.php que configura la contraseña correctamente salada para el usuario dado.

   $ sudo -u apache /usr/bin/php admin/cli/reset_password.php

Conversión del motor de almacenamiento MySQL

If you run your Moodle site with MySQL database backend and use the default MyISAM as the storage engine for your tables, you may want to convert them to use some more reliable engine like InnoDB (actually, you should want to switch to PostgreSQL ;-) anyway).

   $ sudo -u apache /usr/bin/php admin/cli/mysql_engine.php --engine=InnoDB

Herramienta para convertir tablas de innodb a Barracuda

Convertir tablas de InnoDB a Barracuda

Algunos usuarios están obteniendo el siguiente error de MySQL durante la restauración de curso:

 Row size too large (>8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help.

Este error se debe al hecho de el formato de archivo por defecto InnoDB de MySQL (Antelope) no puede manejar más de 10 columnas de texto. Por esto, se le recomienda que cambie el formato de InnoDB a Barracuda usando el siguiente comando:

 php admin/cli/mysql_compressed_rows.php

Para más información sobre los formatos de tablas InnoDB vea:

Correr Cron mediante línea de comando

In versions 1.x, you could execute admin/cron.php either from command line or via the web. Since Moodle 2.0, only admin/cli/cron.php script can be run via command line.

Quehaceres agendados

¡Nueva característica
en Moodle 2.7!

Desde Moodle 2.7

Los Quehaceres agendados are automatically run by the cron script above, but the specific tasks which run on each cron iteration are determined by the scheduled tasks configuration. It is possible to override the scheduled tasks configuration and run a single scheduled task immediately using the admin/tool/task/cli/schedule_task.php script.


This script accepts the following arguments:

--list - list all the known scheduled tasks. The tasks are listed by the class name used to run the task. This class name is required as the argument to the next option in order to run a specific task immediately.
--execute=<task> - Runs a single scheduled task immediately - regardless of scheduling settings. This will even run disabled tasks. Tasks will still use locking to prevent concurrent execution of the same task - even on clusters. The format of the <task> argument must be the same as returned by the --list option above.

Note: You must escape the "\" with an extra \ when using the --execute command. Take the following for example:

php schedule_task.php --list

will return something like:

== List of scheduled tasks (http://yourserver.com/moodle) ==
\enrol_imsenterprise\task\cron_task                10 * * * * *      ASAP
\logstore_legacy\task\cleanup_task                 * 5 * * * *       ASAP
\logstore_standard\task\cleanup_task               * 4 * * * *       Wednesday, November 12, 2014, 4:35 AM
\mod_forum\task\cron_task                          * * * * * *       ASAP
\core\task\automated_backup_task                   50 * * * * *      ASAP

...

To run the first task in that list, you would execute

php schedule_task.php --execute=\\enrol_imsenterprise\\task\\cron_task
php schedule_task.php --execute=\\core\\task\\legacy_plugin_cron_task
Be aware of the double backslashes

Transferencia de BasedeDatos

A command line script for Transferencia de la BasedeDatos may be found in admin/tool/dbtransfer/cli/migrate.php.

Purgar cachés

You can purge caches using this script:

Arreglar secuencias de curso / módulo

In rare cases (such as after upgrading from a very old version of Moodle), the course / section / module sequence data can be out of sync. This can cause various problems for affected courses, such as sections not appearing, backups failing, pages not displaying etc. There is a specific check to check for errors caused by this problem, and to fix the data in the database if they are found. To run this script please use the command below:

 php admin/cli/fix_course_sequence.php -c=* --fix

This will check every course in Moodle and report which ones had errors and were fixed.

Buscar y remplazar texto

This script can be used to search and replace text throughout the whole database. Use carefully and backup first always. More info in Herramienta para buscar y remplazar.

 php admin/tool/replace/cli/replace.php --search=//oldsitehost --replace=//newsitehost


Actualizar imágenes de usuario mediante línea de comando

  http://moodle.org/pluginfile.php/143/mod_forum/attachment/926929/updatepics.php 

Probado en Moodle 2.3.1+

Ponga este archivo en /admin/cli/updatepics.php

Cómo usarlo: Córralo con la opción "dir" para especificar cual directorio contiene los archivos.

  .../admin/cli/updatepics.php --dir=PATH_TO_DIR
  • Los nombres de los archivos deben ser idénticos a los nombresdeusuarios

Gestionar Módulos y bloques mediante línea de comando

Here are two scripts to help you manage your plugins.

  http://tracker.moodle.org/browse/MDL-35736

How to use "manage_blocks.php": place in /admin/cli

hide: ../admin/cli/manage_blocks.php --name=tag_youtube --hide

show: ../admin/cli/manage_blocks.php --name=tag_youtube --show

delete: ../admin/cli/manage_blocks.php --name=tag_youtube --delete

protect: ../admin/cli/manage_blocks.php --name=tag_youtube --protect

unprotect: ../admin/cli/manage_blocks.php --name=tag_youtube --unprotect

(obviously - replace "tag_youtube" with the blockthat you want to remove...)

How to use "manage_mods.php":

hide: ../admin/cli/manage_blocks.php --name=game --hide

show: ../admin/cli/manage_blocks.php --name=game --show

delete: ../admin/cli/manage_blocks.php --name=game --delete

  • Important!

this script does not delete the relevant folder in /moodle/mod or /moodle/blocks

you have to delete it yourself !

Actualización de paquete de idioma mediante línea de comando

 http://tracker.moodle.org/browse/MDL-35735

Ponga el archivo anexo en /admin/cli y símplemente córralo, sin argumentos en línea de comando :)

ReOrdenar lista de cursos mediante línea de comando

 http://tracker.moodle.org/browse/MDL-36237

Ponga el archivo anexo en /admin/cli y simplemente córralo, sin argumentos de línea de comando :)

Yo (el que escribió la documentación en Inglés) importo cursos cada noche desde un sistema externo y después corro éste script