You basically need a command file to run at boot time. There are many ways to do this. For example, I'm under WinXP, so I downloaded cygwin's init module (which emulates system V init) and added the following to the /etc/rc file that init runs at startup:
# Delete postgres sockets
chmod 777 /tmp/.s.PGSQL.*
rm -f /tmp/.s.PGSQL.*
# Delete Postgres PID file
chmod 777 /usr/share/postgresql/data/postmaster.pid
rm -f /usr/share/postgresql/data/postmaster.pid
When the system restarts after being incorectly shut down a PID file is left in the data directory which will stop the service re-starting.
How do you get the operating system to delete this file before attempting to restart the service?
thanks
Richard