So I setup a private instance of Postgresql. Everything is working fine except if Postgres goes down I can't get the cronjob to bring it back up. My Postgres script:
When I run the script I keep getting "Starting up postgres." On pg_ctl.log I get: pg_ctl: invalid data in PID file "{HOME}/pgsql/data/postmaster.pid" On pgsql.log I get: FATAL: bogus data in lock file "postmaster.pid": " " Any help would be appreciated. asked 05 Sep '14, 19:18 jayhalleaux |
I think the problem is that you're overwriting the Try removing the " answered 06 Sep '14, 00:54 seanf So I manually created a postmaster.pid with the correct pid inside and it worked like it should. Now with your suggestion I removed that line from the script, however, no file was created. Is there a setting that I missed? I installed postgresql 9.2 with the make world option so I could have all the extensions.
(06 Sep '14, 01:03)
jayhalleaux
This should be set via the "
(06 Sep '14, 01:42)
ryans ♦♦
|
Add a command after 'starting postgres' which removes the previous PID file before starting. answered 05 Sep '14, 21:20 johns That is not the problem, the problem is that it does not recognize the PID file that was created on the initial startup. Once the postgres is up and running I want it to keep checking if is still running, otherwise create a new instance. If I delete the PID then I will be re-initializing the postgres server every time I run this script which will be every 5 minutes. Also I noticed where the problem is initially: echo $! > "${PIDFILE}" does not place a PID number into the PID file, it just leaves a blank space
(06 Sep '14, 00:10)
jayhalleaux
|
Does your
postmaster.pid
actually contain the PID of your active PostgreSQL process?It does not... just noticed it right now...
The echo $! > "${PIDFILE}" line just inserts a blank space.
In bash, "
$!
" means "the PID of the process just launched in the background". In the watchdog script example, the process is launched in the background with "&
" at the end of the command, so "$!
" makes sense in that context.In your script, however, you're not running it in the background (nor do you want to be), so you'd not want to use "
$!
" at all. Instead, rely on the "$HOME/pgsql/data/postmaster.pid
" PID file that postgresql generates on its own during startup (i.e, remove the "echo $! > "${PIDFILE}
" line).