Set up cron job for Moodle

Cron is required for Moodle to:

  • Send reminder emails.

  • Mark lessons as completed.

  • Update learner status.

  1. Set up cron job for Moodle
  • Run the following command: sudo crontab -u www-data -e in PowerShell.

  • This command opens the crontab file for the www-data user using an editor (usually nano).

  • If this is your first time using crontab, it will ask you to choose an editor: Connect

  • Enter 1 and press Enter. Connect

  • After the editor opens, move to the last empty line and paste the following line:

  • */1 * * * * /usr/bin/php /var/www/html/moodle/admin/cli/cron.php >/dev/null 2>&1

  • Press Ctrl + O → then Enter to save the file, then Ctrl + X to exit.

  • After adding the cron job, you can test it manually with: sudo -u www-data php /var/www/html/moodle/admin/cli/cron.php Connect