Moodle Cron Workaround

Moodle has a cron.php script that takes care of routine tasks, such as unsubscribing inactive members from classes and sending out email messages. Unfortunately, there is no built-in way for this script to run every few minutes when the Moodle installation is inside a protected directory, such as a school Intranet. However, I figured out a workaround.

If you have directory security enabled on your IIS Moodle installation, don’t use MoodleCron. Instead create a Windows Scheduled Task on your server. This passes credentials and executes the cron.php script from the command line, getting around nasty browser authentication issues.

1. Open Control Panel –> Scheduled Tasks on your server
2. Open Add Scheduled Task. Select Next.
3. When asked to select an application, Browse to your PHP installation and select PHP.exe. Select Next.
4. Create a name for the task (I called mine “Moodle cron”)
5. Perform this task “daily.” Select Next.
6. Perform this task “every day” (leave the other items on defaults). Select Next.
7. Enter the name and password of a user who has directory privileges on your /moodle/admin folder. Select Next.
8. Select “Open advanced properties for this task when I click Finish.” Select Finish.
9. Under the Task tab, append the location of cron.php to the Run field, e.g. c:\php\php.exe d:\webroot\moodle\admin\cron.php
10. Under the Schedule tab, click Advanced and then select Repeat Task in order to make the task run more often than once per day. I set mine to run every ten minutes. Select Apply.
11. Select OK. You’re done! Check the Event log later to ensure that the script is not returning errors.


  1. dan says:

    ive been reading your blog for a few months now, and as a fellow educator, you’ve helped avoid some costly mistakes! thank you so much for this blog !

  2. rkassissieh says:

    Thanks, Dan. I always appreciate knowing who is out there and what might be helpful.

  3. Rory Allford says:

    I’d recommend running the scheduled task under the built-in IUSR_[Something] or a manually created unprivileged account, for security reasons, in case the cron script is somehow compromised. See discussion at

  4. rkassissieh says:

    Yes, I suppose so. I don’t know the details of how Windows stores its scripts and how vulnerable this might be.

  5. Paul Raper (Switzerland) says:

    Does this only work if Moodle is installed on a "local" machine? My version of Moodle is installed on an a machine run by my ISP, so I take it this proceedure won’t work.

  6. rkassissieh says:

    Most ISPs have steps you can follow or an admin panel you may use to set up a cron job on your site.

  7. ferdy says:

    Hi! I just would like to inform <a href=""></a> provides free Moodle hosting. Please check it. Cheers.

  8. Henry Ferguson says:

    Thank you Richard! I was struggling for weeks with MoodleCron under Windows Server 2003 and never could get it to run without errors in my Event Logs.

    BTW I found your through the link in Moodle and was suprised to see the Catlin Gabel connection. Both my niece and nephew go there!