How to Set Up Cron for Moodle on Your Mac (The Simple Guide)

When setting up Moodle on your Mac using MAMP Pro, there’s one crucial step that often gets overlooked: setting up the cron job.

If you’re new to this, don’t worry — I’ll walk you through it step-by-step. Setting up cron is essential because it handles all the background tasks Moodle needs to operate properly: things like grading, sending notifications, and performing maintenance tasks.

Without a properly configured cron job, your Moodle site won’t function correctly. So let’s dive in!


Why You Need to Set Up Cron for Moodle

Cron is a background process that automatically runs tasks on a schedule. In Moodle, this process updates the system, grades quizzes, sends out emails, and more. Without it, your Moodle server won’t run efficiently — or worse, might not work at all!

While MAMP Pro makes many things easier, it doesn’t automatically set up cron for you. You’ll need to do this manually. Here’s how.


Step 1: Find Your PHP Version and Document Root

  1. Open MAMP Pro.
  2. Check your PHP Version:
    • On the left-hand sidebar, click on PHP.
    • Write down your current version (e.g., 7.4.21).
  3. Find Your Document Root:
    • Click on Hosts.
    • Find your Moodle site (for example, Moodle 4.0 demo).
    • Write down the path to the Document Root (you’ll need this later).

Step 2: Open Terminal

You’ll need to open the Terminal app on your Mac. You can find it under Applications > Utilities.

Once Terminal is open:

  • Type the following command and hit Enter: nginxCopyEditcrontab -e

This opens your crontab file for editing. If this is your first time, it might be blank.


Step 3: Insert the Cron Job

Now, let’s add the actual cron job.

  1. Press i (this puts you into insert mode).
  2. Go to the bottom of the file (using the arrow keys) and add the following line: swiftCopyEdit* * * * * /Applications/MAMP/bin/php/php7.4.21/bin/php /Users/YourUsername/Sites/Moodle4.0demo/admin/cli/cron.php

Important!

  • Replace php7.4.21 with your PHP version.
  • Replace /Users/YourUsername/Sites/Moodle4.0demo/ with the correct path to your Moodle site.
  • YourUsername will be your Mac user account name.

This command tells the system to run Moodle’s cron script every minute — which is the recommended setting for a local development environment.


Step 4: Save and Exit

Once you’ve added the line:

  • Press Escape (to exit insert mode).
  • Type :wq (which stands for write and quit) and press Enter.

Your cron job is now saved!


Step 5: Restart MAMP Pro

For the cron job to start working:

  1. Go back to MAMP Pro.
  2. Under Hosts, select your Moodle host.
  3. Click Stop, then Start again.

This restarts your local server and activates the cron job.


Step 6: Verify Cron is Working

  1. Open your Moodle site (by clicking Open next to your host in MAMP Pro).
  2. Go to Site Administration.
  3. In the search bar, type Tasks.
  4. Click on Scheduled Tasks.

If cron is working properly, you’ll see that some tasks have started running, showing timestamps for the last and next runs.

If you see tasks running successfully — congratulations! Cron is working perfectly on your Mac.


Final Thoughts

Setting up the cron job might seem a little technical, but once you’ve done it, your Moodle server will be fully functional and ready for use. 🎉

Now that you’ve got everything running smoothly, you can focus on building courses, managing users, and exploring everything Moodle has to offer.


About the Author


Hi, I’m Chris Richter!
If you want to dive deeper into Moodle development or learn how to master Moodle as a teacher, check out my courses linked in the description — there’s over 7 hours of video content covering everything you need to know!

Thanks for reading, and I’ll catch you in the next guide!