Update
You can do this with Screenbar. It gives you a user interface instead of running it in the terminal.
Automate screenshots with shell script
I needed to automate screenshots in mac os x, but i needed to use both my hands to play a game at the same time as i was taking screenshots. So i found this gem at TrickyWays. The following script will take a screenshot with a unique name and save it on your desktop. Just copy and paste it into a terminal window:
Just edit the number 5 to a interval in seconds that fit your needs.