You are here: Home Tech Postgres startup on OS X 10.6

Postgres startup on OS X 10.6

by Chris Shenton last modified Nov 21, 2011 07:23 PM
Use launchd and launchctl to start our hand-built Postgres server on OS X 10.6 Snow Leopard.

Postgres built by hand

I build postgres 8.4.2 by hand with a typical CMMI:

./configure --with-openssl

For this application I didn't need Perl or Python or other stored procedures and options. I probably should have added a couple others like:


It installed in the default location, /usr/local/pgsql.

Then followed the install guides about creating a 'postgres' user, a data dir, changing ownerships, running initd.


I had to increase some kernel values to get initdb to run; in /etc/sysctl.conf:


In order to avoid rebooting, I set these on the live system by using the command:

sudo sysctl -w $VARIABLE=$VALUE

for each variable and value above.


I'm an old FreeBSD/SunOS/Solaris/Linux UNIX guy and launchd is new to me. I eventually pieced together this startup file for OS X. In /Library/LaunchDaemons/org.postgresql.postmaster.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
<plist version="1.0">

In the above I have it logging to a datetime-stamped file which rotates after it gets to be 1MB in size. Remember to create that log dir and make it writable by your postgres user.

Load and go

To get the system to know about it, load it:

sudo launchctl load /Library/LaunchDaemons/org.postgresql.postmaster.plist

It should start automatically. If you've got problems (e.g., bad option switches), it won't start; check /var/log/system.log for complaints.

To stop it, use the label name you gave it in the .plist file (which for sanity, should be the same as the plist file itself, sans suffix):

sudo launchctl stop org.postgresql.postmaster
Share this: