Do wp-cron scheduled tasks run asynchronously?

No, the WP-Cron tasks run asynchronously from the viewing user. They should not see any delay. Although if your task takes more than a minute, it may never finish since most hosts are setup to kill PHP processes after 30 seconds.

get_posts inside cron

Whenever you do get_posts or WP_Query or anything like that, it’s important to remember that the code is actually getting all of the Posts at once, and loading them from the database into memory. If you run out of memory, then your process will simply die with an error. Attempting to get very large numbers … Read more

How can I change the frequency of a scheduled event?

It looks for me that you are adding this event only when there is no such event ‘send_email_alerts_hook’ scheduled yet. Try something like this and let me know if it workded. function shedule_email_alerts() { if ( !wp_next_scheduled( ‘send_email_alerts_hook’ ) ) { wp_schedule_event(time(), ‘daily’, ‘send_email_alerts_hook’); } else { wp_reschedule_event(time(), ‘daily’, ‘send_email_alerts_hook’); } } The thing is … Read more

How to make wp cron job not fire immediately?

As described in wp_schedule_event first parameter is $timestamp – the first time that you want the event to occur. So just add interval to $timestamp. I think it should be like wp_schedule_event( time() + $delay, ‘interval1’, ‘my_cron_hook’ ); And set $delay as miliseconds before hook starts.

Running wp-cron from CLI

Or, you could use WP-CLI which was developed for scenarios like these. After a short installation like this $ curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar $ chmod +x wp-cli.phar $ sudo mv wp-cli.phar /usr/local/bin/wp You can run your scheduled tasks like so $ wp cron event run –due-now –path=/var/www/mywebsite.com/ or via crontab (every 5mins) */5 * * * … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)