I have the following code that creates a CSV and then sends an email:
function generate_and_send_csv()
{
// Removed CSV code for ease of reading
wp_mail('email@address.com', 'New Data Files', 'You have received new data files.', $headers, $filepath);
}
//Create the cron event
if (!wp_next_scheduled('generate_send_csv')) {
wp_schedule_event('1488934800', 'daily', 'generate_send_csv');
}
// Run it
add_action('generate_send_csv', 'generate_and_send_csv');
I then have the following cron set up in cPanel:
php /home/user/public_html/wp-cron.php
After installing the Cronjob Scheduler by chrispage1 plugin, I can see the plugin is correctly scheduling the cron job for 1AM every day. This runs fine, but for some reason I get the email twice.
I know it can’t be anything in my code because when I click the “run” option in the Cron Scheduler plugin, I get the email once. Are there any known issues with WordPress running duplicate cron jobs?