Content-type: text/html
pgnotifyd connects to the current PostgreSQL database, listening for the named asynchronous notification. When notification is received, it executes the given command.
pgnotifyd is useful as an alternative to running a script from a crontab(5) to poll PostgreSQL database for changes.
Note that there are no options for emailing output to administrators. See the EXAMPLES sections for information on how to do this.
The database connection is set using the environment variables and a connection string. The variables used are fully documented in the PostgreSQL manual, the most useful ones being:
The envrionment variables are also inherited by the command run by pgnotifyd, and this can be useful.
Asynchronous notifications are despatched when the transaction completes. When pgnotifyd receives multiple notifications (perhaps due to blocking caused by a previous execution) it will call the command only once.
Wait for user_change notification, and run the sync-htpasswd scripts.
As above, connecting to a specific database (/bin/sh syntax):
Call a shell command on passwd_change notification:
Call a command and email any output to to the administrator, similar to crond(8) behaviour:
Asynchronous notifications can be sent using a trigger; eg.
CREATE OR REPLACE FUNCTION async_notify() RETURNS TRIGGER AS $$ BEGIN EXECUTE 'NOTIFY ' || TG_ARGV[0]; RETURN NEW; END $$ LANGUAGE plpgsql; CREATE TRIGGER user_change AFTER INSERT OR UPDATE OR DELETE ON user EXECUTE PROCEDURE async_notify('user_change');