Tuesday, November 12, 2013

First post

I guess I have to finally create my first post. So let's start with something easy and handy (at least for me :)) .


So these are instructions for setting up a cron job on your localhost using MAMP on a Mac.
  1. In Terminal type crontab -e. This allows you to add a cron job, using the vim editor. 
  2. Press i on your keyboard to go into vim's insert mode. 
  3. 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.
  4. Press escape key to exit vim's insert mode. 
  5. Type ZZ (Must be capital letters -- saves the file and exits crontab). 
  6. 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 1 minute (with */1), so that you can check, reasonably quickly, that it is running. Then edit crontab again and change the curl command to your preferred time.


P.S. This is basically copied from this source, but I might need this info later again, so - easier for me to find it..