If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > PostgreSQL > Auto Truncate

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-29-11, 12:19
joe7670 joe7670 is offline
Registered User
 
Join Date: Aug 2011
Posts: 3
Auto Truncate

Have Postgresql setup for a simple log capture database. Anyone know how to tell the program to automatically truncate entries that are older than 30 days?

My logging software cannot do it and I'd like to do this at the DB automatically.
Reply With Quote
  #2 (permalink)  
Old 09-01-11, 09:25
marc_ marc_ is offline
Registered User
 
Join Date: Aug 2011
Location: Glasgow, UK
Posts: 36
What OS are you using?

For eample if it's Linux/Unix -- you could create a cron job and schedule once a day, every day it to call your sql script that deletes rows > 30 days.

If it's windows use a scheduled task to call your sql delete script.

Alternatively, use a tool like pgAgent:
http://www.pgadmin.org/download/pgagent.php
http://www.pgadmin.org/docs/1.12/pgagent.html

Last edited by marc_; 09-01-11 at 10:25. Reason: Added links
Reply With Quote
  #3 (permalink)  
Old 09-01-11, 15:47
joe7670 joe7670 is offline
Registered User
 
Join Date: Aug 2011
Posts: 3
Great! Got it to work perfect with PGAgent.
Reply With Quote
  #4 (permalink)  
Old 09-01-11, 18:36
marc_ marc_ is offline
Registered User
 
Join Date: Aug 2011
Location: Glasgow, UK
Posts: 36
No worries - Glad it worked for you
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On