First post here, hello all. I've run into a vexing problem where pgagent log reports:
DEBUG: Creating primary connection DEBUG: Creating DB connection: hostaddr=xx.xx.xxx.xxx port=6543 dbname=postgres user=postgres WARNING: Couldn't create connection: fe_sendauth: no password supplied DEBUG: Clearing all connections DEBUG: Connection stats: total - 1, free - 0, deleted - 1 This is occurring on a Debian Lenny box. I did not have this problem on a Gentoo box, but I was a little surprised that the Debian install of pgAgent does not provide an init script for pgAgent. I Googled extensively and couldn't find one, so I took the skeleton example from /etc/init.d and adapted from the Gentoo init script for pgAgent to produce this: #! /bin/sh ### BEGIN INIT INFO # Provides: pgagent # Required-Start: $local_fs $remote_fs $network $time # Required-Stop: $local_fs $remote_fs $network $time # Should-Start: $postgresql-8.4 # Should-Stop: $postgresql-8.4 # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: job scheduler for PostgreSQL ### END INIT INFO # Do NOT "set -e" # PATH should only include /usr/* if it runs after the mountnfs.sh script PATH=/sbin:/usr/sbin:/bin:/usr/bin DESC="job scheduler for PostgreSQL" NAME=pgagent DAEMON=/usr/bin/$NAME DAEMON_ARGS="-l 2 -s /var/log/postgresql/pgagent.log hostaddr=xx.xx.xxx.xxxx port=6543 dbname=postgres user=postgres" PIDFILE=/var/run/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME PGUSER=postgres # Exit if the package is not installed [ -x "$DAEMON" ] || exit 0 # Read configuration variable file if it is present [ -r /etc/default/$NAME ] && . /etc/default/$NAME # Load the VERBOSE setting and other rcS variables . /lib/init/vars.sh # Define LSB log_* functions. # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. . /lib/lsb/init-functions # # Function that starts the daemon/service # do_start() { # Return # 0 if daemon has been started # 1 if daemon was already running # 2 if daemon could not be started start-stop-daemon --start --quiet --chuid $PGUSER --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ || return 1 start-stop-daemon --start --quiet --chuid $PGUSER --pidfile $PIDFILE --exec $DAEMON -- \ $DAEMON_ARGS \ || return 2 # Add code here, if necessary, that waits for the process to be ready # to handle requests from services started subsequently which depend # on this one. As a last resort, sleep for some time. } # TRUNCATED HERE Note the "--chuid $PGUSER" option. This works, as "ps aux |grep pgagent" shows pgagent running under the postgres user. The .pgpass file is located correctly in the postgres user home directory /var/lib/postgresql YET when pgagent runs it does not read the .pgpass file in its own user directory as it does with the Gentoo init script. This is my first init script on Debian but not my first bash script and I cannot work out why the .pgpass file is not being read. All suggestions are gratefully welcome!