mlaks <mlaks@bellatlantic.net> writes:
> I would like to automate this process of deleting postmaster.pid if
> postgresql is not running and would like to ask my question .
It is safe (and probably a good idea) to delete postmaster.pid in a
shell script that runs *ONLY DURING BOOTUP*. Do *not* put such a
command into a script that you might run as a means of manually
restarting the postmaster --- because if you do, you just lost your
interlock against starting two postmasters for the same database.
Which, trust me, is not an interlock you want to lose.
There are quite a few other standard daemons, for instance sendmail,
that have similar issues with leftover lockfiles after a system
crash. If you dig around in your boot scripts you may find one
that's already designed to remove unwanted lockfiles at system boot.
That'd be the place to add "rm /var/lib/pgsql/data/postmaster.pid".
But do not put it into anything that could be triggered after initial
system startup, unless you enjoy the sensation of shooting yourself
in the foot.
regards, tom lane