Start by ensuring that there is actually a 15min interval available.
// create the cron scheduled interval to be used
add_filter('cron_schedules','ex11_cron_schedules');
function ex11_cron_schedules($schedules){
if(!isset($schedules["15min"])){
$schedules["15min"] = array(
'interval' => 15*60,
'display' => __('Once every 15 minutes'));
}
return $schedules;
}
Then create a custom WP_Query loop to fetch all the records you need to compare, and archive those you no longer need (your duplicates):
// I haven't tested this yet. You might need to fine tune it.
// You might also need to tune the query statements to suit the Track CPT
function wpse_archive_duplicate_tracks(){
$args = array( 'post_type'=>'track','pust_status'=>'publish');
$tracks = get_posts($args);
$tracks_to_keep = array();
foreach($tracks as $track){
if (array_key_exists($track->artist . '~' .$track->post_title, $tracks_to_keep)){
$toUpdate = array(
'ID' = $track->ID,
'post_status' = 'archive', // change to 'trash' to delete
);
wp_update_post($toUpdate);
} else {
$tracks_to_keep[$track->artist . '~' .$track->post_title] = $track;
}
}
Finally, you need to schedule your archival function:
wp_schedule_event(time(), '15min', 'wpse_archive_duplicate_tracks');
Parting thought:
You might also want to consider adding a meta_data field to the tracks you have already checked, so you don’t have to check them ALL every time. But … this might not suit your situation, if duplicates can come back anytime.
Good luck!