For instance, since the configured cron tasks will only be run on page load, the task might not be run at the desired interval if there are no visitors.
To prevent this, you need to use your operating system’s task scheduler.
For this, you need to define define('DISABLE_WP_CRON', true);
in your wp-config.php
file. After that, you’d add a crontab configuration like this:
/10 * * * * curl http://YOUR_SITE_URL/wp-cron.php > /dev/null 2>&1
This configuration would call http://YOUR_SITE_URL/wp-cron.php
every ten minutes. Tasks that are scheduled at this point will be executed.
You can also use WP-CLI for that:
*/10 * * * * cd /var/www/example.com/htdocs; wp cron event run --due-now > /dev/null 2>&1