Automating Moodle: basic cronjob solution

If you navigate your moodle administration side and click on “Notifications” you will probably see this statement:
The cron.php maintenance script has not been run for at least 24 hours.

just like this one:

Unless you have already setup an automated way to accomplish this, you want to setup a simple cronjob to ensure yourself that you will never miss another execution of this task that, as you probably already know, is crucial to moodle.

You actually need access to the machine hosting the webside, but if you cannot, you can do this from wherever you can execute wget or similar on a scheduled basis.

Anyway this brief will cover the technique with nano on debian without taking care on wich machine you are.


  1. Copy the url linked from the statement in your moodle instalastion->admin area->Notifications
  2. If you don’t have an open terminal, now it’s time to login into your debian machine
  3. type “crontab -e”, it will open your cronjob file within nano.
  4. add this line to your cronjob:
    26 04 * * * /usr/bin/wget -q http://<<>>/admin/cron.php > /dev/null
  5. press ctrl + “o” <-this is the digit, not the number in order to save your cronjob, do not change the name or the path of the suggested file, it would break the cronjob storage mechanism.
  6. Then press enter to confirm, and then, finally, ctrl + “x” in order to quit
  7. If you made any mistake it won’t save and you will be warned about that, carefully review your crontab -e and compare it to one, already present, that works for sure.
An example us the crontab usage on debian squeeze for moodle cronjob
Click for a fullscreen view of this example

Some needed considerations:

First of all remember to use binary programs in crontab jobs with the full path, on some system they could not work.

As you can see i setup the job to be executed at 04:26 each day, and despite it could sounds inadequate, i learned that it is better to use random minutes (and hours too) in order to avoit that two or more jobs are executed at same time, affecting the overall system performance.


That’s all as usual, should you need help, use comments. 

(Visited 2,718 times, 1 visits today)

Author: Giuseppe Urso

Giuseppe lives in Haarlem now with his shiny dog, Filippa In 1982 received his first home computer, a Commodore 64, followed by Datasette and a 1541 Floppy Disk Drive. In 1999 he installed his first Linux distro (LRH6). In 2006 he switched to Debian as favourite OS. Giuseppe Urso actively sustains the Free Software Fundation and his founder Richard Mattew Stallman, he speaks to people trying to convince them to join the fight now, and about how important is to use Free Software only. He has a job as Infra Specialist at Hippo Enterprise Java Cms an Open Source Enterprise class Content Management System, one of the coolest company ever, in Amsterdam. He's always ready to install Debian on other people computers for free.

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.