From f96c7aff7d7dde7e3c874fb7f7b78e16a11c198f Mon Sep 17 00:00:00 2001 From: f Date: Sat, 23 Apr 2022 16:28:32 -0300 Subject: [PATCH] =?UTF-8?q?volcar=20y=20eliminar=20los=20logs=20del=20d?= =?UTF-8?q?=C3=ADa=20anterior?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/access_logs | 12 ++++++++++++ monit.conf | 5 +++++ 2 files changed, 17 insertions(+) create mode 100755 bin/access_logs diff --git a/bin/access_logs b/bin/access_logs new file mode 100755 index 00000000..2b4fd99f --- /dev/null +++ b/bin/access_logs @@ -0,0 +1,12 @@ +#!/bin/sh +set -e + +# Volcar y eliminar todos los access logs del día anterior +date=`date +%F` + +psql -h postgresql "${DATABASE:-sutty}" sutty < "/srv/http/_storage/${date}.psql.gz" +begin; +copy (select * from access_logs where created_at < '${date}') to stdout; +delete from access_logs where created_at < '${date}'; +commit; +SQL diff --git a/monit.conf b/monit.conf index f574c56d..27605d7c 100644 --- a/monit.conf +++ b/monit.conf @@ -29,3 +29,8 @@ check program blazer as uid "app" and gid "www-data" every 61 cycles if status != 0 then alert + +check program access_logs + with path "/srv/http/bin/access_logs" as uid "app" and gid "www-data" + every "0 0 * * *" + if status != 0 then alert