Обсуждение: daily check for expired data ?

Поиск
Список
Период
Сортировка

daily check for expired data ?

От
Ralf Weidemann
Дата:
Hi all,

how could I do an automatic daily check
to delete some expired data ? I mean
can I have a cron functionality in post-
gresql ?

Thanks,
Ralf




Re: [GENERAL] daily check for expired data ?

От
Herouth Maoz
Дата:
At 22:48 +0200 on 11/3/99, Ralf Weidemann wrote:


>
> how could I do an automatic daily check
> to delete some expired data ? I mean
> can I have a cron functionality in post-
> gresql ?

You don't need to have cron functionality in postgresql when you have cron
functionality in cron. :)

What you have to do is make a simple script, more or less like this:

#!/usr/bin/sh
PGHOST=...
PGPORT=...
PGUSER=...
psql my_database <<END_SQL
DELETE FROM table_in_question
WHERE datetime_field < ( 'now'::datetime - '1 day'::timespan );
END_SQL

And then run it with cron...

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma