Reputation: 39
So basically I have a table called acc_rec_pay_old
which stores the deleted data, the table has its own date so how can I delete all records from acc_rec_pay_old
after 2 years AUTOMATICALLY
?
Upvotes: 1
Views: 185
Reputation: 1141
Write a script in whatever language your comfortable with, create a config file which reads your table name and duration of records to be kept.
Run this via crontab
Upvotes: 0
Reputation: 7597
Setup a cronjob that runs every day that executes the following query:
DELETE FROM acc_rec_pay_old WHERE DATE_ADD(date_field, INTERVAL 2 YEAR) = CURRENT_DATE;
Upvotes: 3