Skip to content

101t/psql-email-alert

Repository files navigation

Gorilla

This is an example of Email alert using PostgreSQL with PL/Python inside.

Instructions:

  1. Download the script into Ubuntu Server git clone https://github.com/101t/psql-email-alert /opt, then Install PL/Python and PostgreSQL.
  2. Connect to postgresql sudo -u postgres psql
  3. create database called gorilladb:
create database gorilladb;
grant all privileges on database gorilladb to postgres;
\q
  1. instal pl/python, run the following command:
sudo apt-get install -y postgresql-plpython3-*

then go to gorilladb and type run:

CREATE OR REPLACE LANGUAGE plpython3u;
  1. you can run script in /opt/psql-email-alert/main.sh
  2. copy and append gorilla.cron script into nano /etc/crontab then:
cat /opt/psql-email-alert/gorilla.cron >> /etc/crontab # please don't do this twice
  1. check the mail cron in terminal using:
systemctl status cron
systemctl restart cron