I have a Postgres Docker container and have installed systemd, pgagent, and created pgagent.sh and pgagent.conf using the following example: https://gist.github.com/v4r15/b246b81ec09c488ebecac4610d975456
If I start pgagent manually using the following command it works fine and I can schedule backups etc..
/usr/bin/pgagent hostaddr=127.0.0.1 dbname=postgres user=postgres -s pgagent_log.log
However, I cannot seem to get pgagent to start automatically on startup or reboot.
Has anyone been able to get this to work on Debian.It's actually the Bitnami Docker image with PostreSQL pre-installed.
I modified the code from the link above and put it in /etc/init.d/pgagent.sh (below):
#!/bin/sh## start/stop pgagent daemon.set -e### BEGIN INIT INFO# Provides: pgagent# Required-Start: $network $local_fs postgresql# Required-Stop: $network $local_fs postgresql# Default-Start: S 2 3 4 5# Default-Stop: 0 1 6# Short-Description: pgAgent### END INIT INFO. /lib/lsb/init-functionspath2bin="/usr/bin/pgagent"if ! test -f $path2bin; thenlog_failure_msg "$path2bin not found"exit 1fiRUN_AS="postgres"CONNECT_STRING="/usr/bin/pgagent hostaddr=127.0.0.1 dbname=postgres user=postgres"LOGLEVEL=0LOGFILE="/var/log/pgagent/pgagent.log"if [ -f /etc/default/pgagent ]; then. /etc/default/pgagentelif [ -f /etc/pgagent.conf ]; then. /etc/pgagent.conffiif [ "$CONNECT_STRING" = "" ]; thenlog_failure_msg "CONNECT_STRING not specified"exit 1fiopts="--quiet --oknodo --exec $path2bin"case "$1" instart) log_begin_msg "Starting PgAgent daemon..." if pidof $path2bin > /dev/null; then log_begin_msg "Already running" log_end_msg 0 exit 0 fi if [ "$RUN_AS" != "" ]; then opts="-c $RUN_AS $opts" if [ ! -f "$LOGFILE" ]; then touch $LOGFILE; fi chown $RUN_AS $LOGFILE fi OPTIONS="-l $LOGLEVEL -s $LOGFILE $CONNECT_STRING" start-stop-daemon --start $opts -- $OPTIONS log_end_msg $? ;;stop) log_begin_msg "Stopping PgAgent daemon..." start-stop-daemon --stop $opts log_end_msg $? ;;force-reload) $0 restart ;;restart) $0 stop $0 start ;;status) if ! pidof $path2bin > /dev/null; then log_success_msg "PgAgent isn't running" exit 3 fi log_success_msg "PgAgent running" exit 0 ;; *) log_success_msg "Usage: $0 {start|stop|force-
reload|restart|status}"exit 1;;esac
exit 0