I created a new plugin in wordpress, which schedules a cron when it is activated. The scheduling part looks like this:
$crons = _get_cron_array();
//Use wp_next_scheduled to check if the event is already scheduled
$timestamp = wp_next_scheduled('customers-hourly');
if($timestamp == false) {
//Schedule the event for right now, then to repeat daily using the hook 'wi_create_daily_backup'
wp_schedule_event(time(), 'hourly', 'customers-hourly');
}
$crons = _get_cron_array();
add_action('customers-hourly', [$this, 'hourlyCron']);
When stepping through the code with the debugger, after activating the code, _get_cron_array contains this:
$cron = [ // 12 elements
[.. snip other crons ..]
1493335692 => [
'customers-hourly' => [
'schedule' => 'hourly',
'args' => [],
'interval' => 3600,
],
],
'version' => 2,
];
So my cron is definitely there. When I load up the cron.php directly and _get_cron_array() is called, it shows 19 elements, none of which are the customers-hourly.
Any idea what is causing this?
One major detail I overlooked is that I'm using multi-site. The cron was created on the network site, while I was running the cron from one of the sites. Running the cron from the network site instead showed all of the crons I was seeing in admin and fixes the issues.
End result: problem existed between keyboard and chair.