cron 作业从 debian 上的 postgres 中删除旧数据 [英] cron job to remove old data from postgres on debian
本文介绍了cron 作业从 debian 上的 postgres 中删除旧数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I need to create a cron that runs every night and remove some of the data (older ones) from my database. I am running postgres on debian. How do I do that? My server is tomcat6. Does anyone have a step by step instruction including script to do that?
解决方案
in most cases, I prefer a shell script with an here-document. (shell-variables expand nicely in here-documents):
#!/bin/sh
PSQL=/local/postgres/bin/psql
SOME_VALUE=123
$PSQL my_database <<THE_END
DELETE FROM my_table
WHERE my_column <= $SOME_VALUE
;
THE_END
这篇关于cron 作业从 debian 上的 postgres 中删除旧数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文