is WGET correct for this cron job?
wget was fine. The client’s theme had a coming soon feature that was keeping the cron from processing.
wget was fine. The client’s theme had a coming soon feature that was keeping the cron from processing.
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
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
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.
This will run the command foo at 12:00AM on the first of every month 0 0 1 * * /usr/bin/foo This article describes the various fields, look to the bottom of the page: http://en.wikipedia.org/wiki/Cron To add this to your cron file, just use the command crontab -e
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
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
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
You’re looking for wp_schedule_event which hooks into the WordPress cron. Cron’s job is to run tasks periodically from the back end.
A simple and dynamic way to use WordPress cron would be to set up an action hook for your schedule then only add scheduled events as and when you need them. The events would call a generic function and pass in your specific custom post type details through $args – add_action(‘my_schedule_event’, ‘generic_function’); function set_schedule($post_id) { … Read more