• We’ve tried disabling the WP Cron and instead running the cron via a server command: "wget -q -O - https://xxxxxxxx.co.uk/wp-cron.php?doing_wp_cron" but my colleague is receiving timeout reports and WP Crontol is reporting that the crons aren’t running reliably. The server cron job interval is set to 45 minutes, but we have also tried smaller intervals. Any ideas why this isn’t working?

    • This topic was modified 2 years, 10 months ago by rokkashthomas.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    If you disabled WP Cron, why would you expect requesting wp-cron.php to work? For server cron to work, you need to enter commands at /etc/crontab/. The crontab command could execute a bash script that does a sequence of commands. But none of them should include wp-cron.php if it has been disabled.

    Thread Starter rokkashthomas

    (@rokkashthomas)

    Hi @bcworkz, thanks for your reply. We’ve followed the process outlined here: https://kinsta.com/knowledgebase/disable-wp-cron/ which implies that the server cron command should still run even if WP Cron is disabled. Unfortunately I don’t think we have access to /etc/crontab/ due to our hosting setup, but what command would we need to add there if we are able to access it?

    Moderator bcworkz

    (@bcworkz)

    I don’t know where DISABLE_WP_CRON is checked, so cannot confirm if requesting wp-cron.php should work or not. Time out problems could mean it doesn’t (the situation may have changed since last August), or something else could be wrong with the events wp-cron.php is executing. WP Control could be responding to DISABLE_WP_CRON itself or maybe there really is something else wrong, IDK.

    Adding cron jobs via c-Panel as shown in the kinsta article you linked is tantamount to editing /etc/crontab. You can work around wp cron entirely by creating a callback that handles requests to /wp-admin/admin-post.php?action=your-fn-name. (works sort of like WP Ajax) Make a crontab entry that makes such a request.

    Maybe even better is to create an custom REST API route/endpoint that can be requested from crontab. Anyway, the point is to make a direct request to do something without involving WP cron. Because crontab is managing the time intervals, there’s little reason to involve WP cron at all.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Trouble with cron jobs’ is closed to new replies.