Are wordpress cron jobs executed sequentially or in parallel? Are wordpress cron jobs executed sequentially or in parallel? wordpress wordpress

Are wordpress cron jobs executed sequentially or in parallel?


As mentioned, installing a cron plugin will help to manage your crons.

To answer your question, Wordpress uses a "cron lock" defined('DOING_CRON') and sets a transient $lock = get_transient('doing_cron') when the spawn_cron method is invoked.

So, if you have a look at wp-includes/cron.php you'll see Wordpress crons do not run concurrently by default and will not run more than once every 60 seconds.

// don't run if another process is currently running it or more than once every 60 sec.    if ( $lock + WP_CRON_LOCK_TIMEOUT > $gmt_time )        return;


If you can only send one or two emails at a time this is going to be tricky to solve. An easier way to solve this would probably be to have WordPress use an SMTP email server that allows the frequency of emails you need to send. Just adding a new email account on your current hosting provider might suffice. If you do not know how to set that up manually there are plugins that will do that for you.


As php runs from top to bottom so when you schedule a event using wordpress schedule event function, as below :

if (! wp_next_scheduled ( 'my_hourly_event' )) {    wp_schedule_event(time(), 'hourly', 'my_hourly_event');}add_action('my_hourly_event', 'do_this_hourly');function do_this_hourly() {    // do something every hour}

This function do_this_hourly() will run as per the schedule , but the code which you will write inside that function will run one by one only.

  1. Let us take example of email sending to 5 persons, so the email will be sent to them one by one in a loop.
  2. The time-stamp is entered by the insert query which you are using, there is no connection between the timestamp and the mail sent time, this timestamp you have created for your own logs , so that you can check.

There would be some difference for sure i:e 10 seconds, it can also be less or greater, depending on the time which server is taking to send email and process the insert query.

Each query will be fired and the timestamp will be inserted according to the time at that moment (server time).