I am new with WordPress development and using cron job for first time. I am having issue with cron job which is not firing. Here are all steps i have taken to achieve this. I have put this line in my wp-config file
define('DISABLE_WP_CRON', true);
Then i have setup a cron job in my cpanel with this command.
wget -q -O - http://mywebsite.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1
I have select interval for every 30 minutes.
But now cron job not firing my WordPress function. Here is my code that i am using in functions.php of my theme.
wp_schedule_event(time(), 'hourly', 'my_hourly_event');
add_action('my_hourly_event', 'do_this_hourly');
function do_this_hourly() {
wp_mail( '[email protected]', 'Automatic email', 'Automatic scheduled email from WordPress to test cron');
}
Can anybody tell me what i am doing wrong with this because i am not receiving emails from this function. I will really appreciate your help.
Thank you!
>/dev/null 2>&1
from de command to check if the system cron is fired or not and then isolated the problem to the PHP code.