How can I start postgres automatically on startup? I can start postgres with:

# Start Postgres
/usr/local/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start


Where can I put that to start up when I start the machine up?

I can put it in my .bash_login file but then I get a new instance of postgres each time I do a new window which is not good.

I only want it to happen when I initially log in to the machine.

This is for OS-X Lion, Macbook Air bought Nov 2011
In general for Apple systems you should add a .plist to your Launchd configuration.

Exactly how to do this varies a little from Mac OS X release to Mac OS X release. You haven't specified yours so I can't give a more specific answer.

The main thing to be aware of is that your postgresql plist should make sure to run PostgreSQL as the correct user.

If you use the EnterpriseDB installers for PostgreSQL they should take care of this task for you.