This is an example of Email alert using PostgreSQL with PL/Python inside.
- Download the script into Ubuntu Server
git clone https://github.com/101t/psql-email-alert /opt, then InstallPL/PythonandPostgreSQL. - Connect to postgresql
sudo -u postgres psql - create database called
gorilladb:
create database gorilladb;
grant all privileges on database gorilladb to postgres;
\q- 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;- you can run script in
/opt/psql-email-alert/main.sh - copy and append
gorilla.cronscript intonano /etc/crontabthen:
cat /opt/psql-email-alert/gorilla.cron >> /etc/crontab # please don't do this twice- check the mail cron in terminal using:
systemctl status cron
systemctl restart cron