Configuring cron jobs on MAMP localhost
These are instructions for setting up a cron job on your localhost using MAMP on a Mac.
- In Terminal type
crontab -e. This allows you to add a cron job, using the vim editor. - Press
ion your keyboard to go into vim's insert mode. - Type in you cron command. For example, to run at minute 5 of every hour using curl, use:
5 * * * * /usr/bin/curl --silent --compressed http://localhost:8888/cron.php
But to run every 5 minutes, use:
*/5 * * * * /usr/bin/curl --silent --compressed http://localhost:8888/cron.php
Note that if you are not using MAMP's default 8888 port, you should leave that off. - While in insert mode you can use the arrows and delete keys as you would normally.
- Press escape key to exit vim's insert mode.
- Type
ZZ(Must be capital letters -- saves the file and exits crontab). - Verify the cron job details by typing
crontab -l(that's a lower case L) at the terminal prompt.
I recommend that you first try setting the job to run every 2 minutes (with */2), so that you can check, reasonably quickly, that it is running. Then edit crontab again and change the curl command to your preferred time.
Non-Vim althernative
For those with a reservation against Vim (or any other command-line editor), you can do it like this:
- Create a document with your editor of choice.
- Add the cronjobs you want to add, like described above.
- Save the file as "mycron.txt" on your desktop (or any other place you like).
- Open up a Terminal window, and go to the desktop ( cd ~/Desktop ).
- Type in crontab mycron.txt
- Type in crontab -l to verify that your commands were added to cron.
Note: This method will overwrite the entire crontab, so keep the mycron.txt file available. When you need to add or change cronjobs, just edit that file and repeat the crontab mycron.txt command to update your cronjobs.

MacOS X >10.5 uses launchd instead of cron
MacOS X after 10.5 no longer seems to use cron and has replaced it by launchd. This uses plist files to register jobs to run. To access cron.php using launchd place the following file in /Users/your_account/Library/LaunchAgents/com.your_site.drupal_cron (create the directory if necessary):
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.your_site.drupal_cron</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/curl</string>
<string>--silent</string>
<string>--compressed</string>
<string>http://localhost:8888/cron.php</string>
</array>
<key>StartInterval</key>
<integer>300</integer>
</dict>
</plist>
This will then get loaded when you login and will visit the cron.php page every 300 seconds (5 minutes). To make it take affect you need to logout/login or use the terminal to run launchctl to load it immediately:
launchctl load /Users/your_account/Library/LaunchAgents/com.your_site.drupal_cronIf you need to change the plist file you can unload and reload it again with:
launchctl unload /Users/your_account/Library/LaunchAgents/com.your_site.drupal_cronlaunchctl load /Users/your_account/Library/LaunchAgents/com.your_site.drupal_cron
(If you have XTools installed you can use /Developer/Applications/Utilities/Property List Editor to create plist files.)