looking for some assistance.
I have searched the usual sites but not come across this specific question and was wondering if anybody could help. I have a scrape system that collects data and saves it to my database in wordpress. It is saving the track history for a radio station. Unfortunately I am getting double ups which I can't fix. I'd like to run a cron job that reviews the last 30 entries for that custom post type (track) and if it finds any duplicates it deletes all but the oldest.
The image shows an example of the issue.
The tracks highlighted in blue need to be deleted automatically by the system as they aren't needed.
So in summary Cron needs to run every 15 minutes. It needs to look for the last x entries (maybe 30). It needs to look for any duplicates. It needs to delete all but the oldest of those that it finds (that keeps the information about when it first played). This should be a very light job to avoid high cpu.
Any help would be much appreciated.