Tell me more ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.


I'm trying to make a clean startup script for pgagent
I found one here that use start-stop-daemon :

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

I wanted to run this under the postgres user, because it's more appropriate and because it allows the command to get the password in the .pgpass file. So, as the start-stop-demon doc says, I added -c postgres:postgres in the call :

if start-stop-daemon -S -q -p /var/run/pgagent.pid -c postgres:postgres \
-x /usr/bin/pgagent "hostaddr=127.0.0.1 dbname=postgres user=postgres";then

But when I test my script with sudo /etc/init.d/pgagent start, I still get the error showing that the .pgpass file is not used at all...

WARNING: Couldn't create the primary connection (attempt 1): 
fe_sendauth: no password supplied
share|improve this question
A quick browse through man start-stop-daemon suggests that you want --chuid postgres. Do you get any error messages? – geirha Mar 7 '11 at 6:56
yes, that's what -c postgres:postgres stand for. The problem is that the underlying process is not using the .pgpass file located in postgres home folder like it should. – Dominique Guardiola Mar 7 '11 at 14:58
That's odd. I made a simple script that just did env > /tmp/env.output, then ran that using a similar line: sudo start-stop-daemon -S -q -c tmpuser:tmpuser -x /usr/local/bin/tmpscript and in /tmp/env.output, the HOME environment variable was set to tmpuser's homedir. – geirha Mar 8 '11 at 15:59
Try adding -l 2 to the args for pgagent for more verbose logging and post back. – ed. Sep 14 '11 at 17:24
sorry , I turned out to use the password in the command line, this was a while ago now – Dominique Guardiola Sep 14 '11 at 20:57
show 1 more comment

closed as too localized by jrg, Jorge Castro, htorque, RolandiXor, Marco Ceppi Nov 7 '11 at 14:49

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.