Sending out scheduled emails

You cannot rely on wp-cron for consistent results so you have to look to the server level. Most enterprise-level WordPress installations need some sort of consistent automation. This is how I automate WordPress in this type of situation. You will need to add a crontab to the server itself. If you’re running Linux, you can … Read more

execute function in wordpress plugin using crontab

I found a great solution here: Trigger a custom wordpress plugin with a linux cron My path was /usr/bin/wp so check your server. You can just add your function to a file, and using the wp bin script you don’t need to add anything to your php file to use WordPress functions. I was able … Read more

Schedule event every second thursday of the month

WordPress lets you add custom cron schedules, which is normally what you’d want to do in this situation, in conjunction with wp_schedule_event(). But, they work based on intervals rather than specific dates/times. For instance, add_filter( ‘cron_schedules’, ‘addCustomCronIntervals’ ); function addCustomCronIntervals( $schedules ) { $schedules[ self::PREFIX . ‘debug’ ] = array( ‘interval’ => 60 * 2, … Read more

WordPress Cron Schedule the if and else statement

wp_cron is a PHP level system and so also only runs on page load. It does not run on clock time so you’d still need to reload the page to get the loop to run. Second, to get this working with wp_cron you’d need to pull all of your posts with _limited_dates_to set and loop … Read more

Run function at specific time

you can absolutely use wp_cron to specify a time: add_action( ‘my_scheduled_event’, ‘prefix_my_scheduled_event’ ); /** * On the scheduled action hook, run a function. */ function prefix_my_scheduled_event() { // do something } //going to use the strtotime function, so a good habit to get into is to set the PHP timezone to UTC default_timezone_set( ‘UTC’ ); … Read more

Trigger a cron every 24h GMT -8

Almost, WP Cron jobs do not run at specific times, they are approximate, and all timestamps should be UTC, as WordPress always deals in UTC timestamps. If you want midnight PST, you’ll want to specify 8PM UTC. Also for example, your above code suggests midnight PST, but it may not run at midnight PST. If … Read more

Cronjob not working as expected – issue with hook?

Unfortunately the WordPress cron jobs are only triggered when your site is visited (see Codex): The action will trigger when someone visits your WordPress site, if the scheduled time has passed. I believe this to get around the fact that many on shared hosting aren’t normally allowed to set up cron jobs (at least, not … Read more

Cron jobs for deactivated plugins

This might be because the plugins you were using didnt deregister the crons it setup. To remove the crons use the following code in your functions file: add_action(“init”, “clear_crons_left”); function clear_crons_left() { wp_clear_scheduled_hook(“cron_name”); } Once thats run once you can safely remove it