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 i on 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.
We 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.