Cron jobs allow you to automate routine and repetitive tasks on the server such as sending out email messages and unsubscribing inactive members from classes. In Moodle this is done by the cron.php script. However there is no built-in way for this script to run every few minutes from Moodle, so you have to get some outside help.
One way of automating this task is to install the Moodle Cron Package. It simply installs a new Windows Service that will automatically run the cron.php script. However, if you have directory security enabled on your IIS Moodle installation - and you will need to if, for example, you want to use NTLM/LDAP authentication - don't use MoodleCron. A better way to run the cron.php script on Windows is to create a Scheduled Task in the Windows Scheduler on the server.
Another good reason for using a Scheduled Task on Windows is that if the Cron Script (cron.php) is called over HTTP (e.g. using WGET or CURL) it can use up a large amount of memory on large Moodle installations.








Note
You can log the output of the cron script as it executes. This is useful if, for example, you see the job is generating errors, backups are not being completed or users are not receiving forum emails. To enable logging, adjust the command so that it uses php.exe and specify the name and path of the log file, example:
C:\PHP\php.exe -f C:\moodle\admin\cron.php > C:\moodle\admin\cron.log
Note
You should run the scheduled task under a user account whose password does not expire. If the user password does expire then the scheduled task will not run when the password has expired and you might spend hours trying to find out why it is not running. One way to get around this is to create a new user in Windows specifically for running the scheduled task. The Password never expires option for this user must be selected.


Note
To check if the task completed successfully look at the Last Result column. The 0x0 code indicates that the task completed successfully. Additionally if you click the View Log option on the Advanced menu in Windows Explorer the log file for the task will be displayed.
If you find that the Moodle Cron script is not running properly it is most likely because that user that you are running the Scheduled Task under does not have the right permissions to execute the Moodle Cron script.
The Moodle setup is now finished. The final step is to test the installation thoroughly and load a few users and some content. But first grab a drink and congratulate yourself!
Note
If you experience any problems setting up the cron job read the official Moodle Cron documentation and the excellent Q308558 article on the Microsoft Knowledge Base.