Pgagent startup script (under the postgres user)

Posted by Dominique Guardiola on Ask Ubuntu See other posts from Ask Ubuntu or by Dominique Guardiola
Published on 2011-03-06T14:54:46Z Indexed on 2011/03/06 16:18 UTC
Read the original article Hit count: 417

Filed under:
|
|
|

Hello,
I'm trying to make a clean startup script for pgagent
I found one here but I don't see how I can change this :

if start-stop-daemon --start --quiet --pidfile /var/run/pgagent.pid \
--exec /usr/bin/pgagent "hostaddr=127.0.0.1 dbname=postgres user=postgres \
password=XXXXXXX";then

to launch something like this :

su - postgres -c /usr/bin/pgagent "hostaddr=127.0.0.1 dbname=postgres user=postgres"

in order to avoid to hard-code the PG password in the script.
This is possible using the .pgpass file feature. It works when I'm logged under the postgres user.

So my only problem left is how to launch this command under the postgres user tried to add --user=postgres in the call, like mentioned here but it does not work.

© Ask Ubuntu or respective owner

Related posts about bash

Related posts about init.d