Cron con Windows

De MoodleDocs

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)

Hay dos maneras diferentes de crear un disparador de proceso Cron de Moodle en sistemas operativos Windows.

Paquete de cron Moodle

Use the Moodle Cron package. The simplest way is to use this little package MoodleCron-Setup.exe, which makes this whole thing very easy by installing a small Windows service. Run it and forget about it! :-)

Tarea agendada wget o php

If you prefer to use the built-in Windows Scheduler or are having trouble with moodle-cron-for-windows package, you can use wget for windows or php from the command line and setup a scheduled task. Just follow these steps:

    • Choose either the php.exe/php-win.exe (command line binary) or wget
The php.exe or php-win.exe binary (for PHP version 5 or later) is installed in your php folder (e.g. c:\php) will give you better performance when running the cron script.
If you want to use wget, download a compiled version of wget for windows from the native GNU Win32 ports (, from Heiko Herold's wget for windows page ( or Bart Puype's wget for windows page ( If you use Heiko Herold's package, copy all of the .DLL files to your C:\Windows\system32 directory. Copy the wget.exe file to c:\windows (this makes sure wget is always in the search path).
  • Setup a Scheduled Task.
- Go to Start >> Control Panel >> Scheduled Tasks >> Add Scheduled Task.
- Click "Next" to start the wizard:
- Click in the "Browse..." button and browse to c:\php\php.exe or c:\windows\wget.exe and click "Open"
- Type "Moodle Cron" as the name of the task and select "Daily" as the schedule. Click "Next".
- Select "12:00 AM" as the start time, perform the task "Every Day" and choose today's date as the starting date. Click "Next".
- Enter the username and password of the user the task will run under (it doesn't have to be a priviledged account at all). Make sure you type the password correctly. Click "Next".
- Mark the checkbox titled "Open advanced properties for this task when I click Finish" and click "Finish".
- In the new dialog box, type the following in the "Run:" text box:
c:\windows\wget.exe -q -O NUL
c:\php\php-win.exe -f c:\moodle\admin\cli\cron.php
Replace "c:\moodle" with the path to your moodle directory or "" with the name of your site.

- Click on the "Schedule" tab and there in the "Advanced..." button.
- Mark the "Repeat task" checkbox and set "Every:" to 5 minutes, and set "Until:" to "Duration" and type "23" hours and "59" minutes.
- Click "OK" and you are done.

NOTA: Si usa la versión de wget, asegúrese de revisar las Configuraciones de cron para asegurarse de que el servicio cron 'basado en web' está permitido.

  • Test your scheduled task. You can test that your scheduled task can run successfully by clicking it with the right button and chosing "Run". If everything is correctly setup, you will briefly see a DOS command window while wget/php executes and fetches the cron page and then it disappears. If you refresh the scheduled tasks folder, you will see the Last Run Time column (in detailed folder view) reflects the current time, and that the Last Result column displays "0x0" (everything went OK). If either of these is different, then you should recheck your setup.
  • Logging cron output. You may want to log the output of the cron script as it executes, in case you see the job is producing errors, backups are not being completed or users are experiencing delays in receiving forum emails. To do this, adjust the command so that it uses the php.exe and stores the output in a file called (for example c:\moodle\admin\cron.log). Here is an example of the php.exe command:
c:\php\php.exe -f c:\moodle\admin\cron.php > c:\moodle\admin\cron.log

If you experience problems logging the output of cron.php to a text file using the above command then read this message by Iñaki Arenaza for an alternative way to log the output of Cron.

Another method is to create a small batch file on your server that does all the work and get the scheduled task to call that file. Here is an example of a batch file that saves the output of cron to a file and deletes log files older than 5 days.

@echo off
set phppath="C:\Program Files (x86)\PHP\v5.3\php.exe"
set cronpath="C:\moodle\moodle-test\wwwroot\admin\cli\cron.php"
set logpath="D:\moodle\moodle-test\cronlogs"

%phppath% -f %cronpath% >> %logpath%\%date:~10,4%%date:~4,2%%date:~7,2%.log

Forfiles /P %logpath% /S /M *.log /D -5 /C "cmd /c del /q @path"

Cron en entorno Windows 10/Xampp

El configurar un trabajo Cron en Xampp funciona empleando el Agendador de trabajos (Task Scheduler). El usar wget o MoodleCron es dificil e incierto. Use la línea:

c:\php\php.exe -f c:\moodle\admin\cron.php > c:\moodle\admin\cron.log

en el diálogo de Acción, y asegúrese de que configure correctamente el tiempo.