0

In my wp-config.php, I have

define('DISABLE_WP_CRON', true);

I am on a Mac (Catalina), and if I run from the terminal crontab - l I see

* * * * * wget -q -O - 'https://mysiite.com/wp-cron.php?doing_wp_cron&cron=true'; echo "wordpresscron" >> /somepath/stdout.log

In my log file, I see wordpresscron being echoed.

But when I view my apache access log I don't see any GET requests related to the cron.

Now, if I manually enter at the terminal

wget -q -O - 'https://mysiite.com/wp-cron.php?doing_wp_cron&cron=true'

An entry gets written into the apache access log.

So I just can't figure out what is going on. Seems my cron is working, but apache log is not showing this...

Ideas?

Edit:

Maybe this has something to do with the fact that I am changing the system time on my MAC to test the triggering of events?

For instance, take a look at this output showing jobs that are pending:

enter image description here

So there are some jobs to run. If I type from the terminal

wp cron event run --due-now

These pending jobs all get immediately completed. I modified my crontab a bit, it is now

* * * * * cd /sitefolder; wp cron event run --due-now; echo "ran cron" >> /users/brian/sites/stdout.log

And I see ran cron being echoed to the log.

So I am truly at a loss. It is as if the cron is running, and when the wp cron event run --due-now command is issued, it is ignored, and I can't imagine the conditions under which it might be ignored when ran as a cron. Maybe when ran as cron it is being ignored because it sees that I made a system time change (although I can't imagine why that would cause a command to be ignored). Or could it be a weird permissons issue, in which case at command line I have permissions to run wp cron event run --due-now, but the cron job somehow does not have permission?

Anyway, this is driving me nuts.

1 Answer 1

1

Ok, things are working now. Not sure if it was fact that cron environment didn't have its PATH set as needed, or if there was other reason, but I followed the instructions here:

https://peterwilson.cc/real-wordpress-cron-with-wp-cli/

and

https://purpleturtlecreative.com/blog/2020/02/how-to-replace-the-wordpress-cron-with-a-linux-cron-job/

So now, my crontab is

PATH=/usr/local/opt/[email protected]/bin:/usr/local/opt/[email protected]/bin:/usr/local/opt/[email protected]/sbin:/usr/local/opt/[email protected]/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
* * * * * /bin/bash /folder/wordpresscron.sh

(with newline after the crontab entry)

And the script:

#!/bin/bash
clear
cd /site
for hook in $(wp cron event list --next_run_relative=now --fields=hook --format=ids);
  do wp cron event run "$hook";
done;
echo "now in cron" >> /folder/stdout.log

Anyway, glad I can move on now!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.