wp_schedule_event action not running

I think your problem may be in the use of $post->ID. In your code $post is an undefined variable. As you are inside a loop, try get_the_ID() instead of $post->ID: $post_ID = get_the_ID(); $request_start_time = get_post_meta( $post_ID, ‘_simple_start_date’, true ); if (date(‘Ymd’) == date(‘Ymd’, $request_start_time)){ $current_user = $post->post_author; $request_date = get_post_meta( $post_ID, ‘_simple_start_date’,true ); $request_year … Read more

wp_schedule_event didn’t work

Cron fires outside of the standard WordPress loop, so $post will not be filled with any post-related data when the function is called. It should be obvious, then, that providing an ID directly isn’t referencing the non-existent $post variable which is why it works in that scenario. The best way to set post_statuses to expired … Read more

escaping double quotes and percent signs (%) in cron

You have to escape the % signs. They have a special meaning in crontabs: man (5) crontab: Percent-signs (%) in the command, unless escaped with backslash (\), will be changed into newline characters, and all data after the first % will be sent to the command as standard input.

Prevent duplicate cron jobs running

There are a couple of programs that automate this feature, take away the annoyance and potential bugs from doing this yourself, and avoid the stale lock problem by using flock behind the scenes, too (which is a risk if you’re just using touch). I’ve used lockrun and lckdo in the past, but now there’s flock(1) … Read more

Cron job for let’s encrypt renewal

Monthly is not frequent enough. This script should run at least weekly, and preferably daily. Remember that certs don’t get renewed unless they are near to expiration, and monthly could cause your existing certs to occasionally be expired already before they get renewed. The name of the program is certbot, which was renamed from letsencrypt. … Read more

Running a cron job manually and immediately

Here’s what I did, and it seems to work in this situation. At least, it shows me an error, whereas running from the command line as the user doesn’t show the error. Step 1: I put this line temporarily in the user’s crontab: * * * * * /usr/bin/env > /home/username/tmp/cron-env then took it out … Read more

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