As of May 31, 2023, we have updated our Code of Conduct.

Questions tagged [cron]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
29 votes
2 answers
22k views

How to test wp_cron?

This is kind of a stupid question... I scheduled a action to run every hour: if(!wp_next_scheduled('my_hourly_events')) wp_schedule_event(time(), 'hourly', 'my_hourly_events'); add_action('...
onetrickpony's user avatar
  • 13.6k
28 votes
4 answers
48k views

How to debug WordPress "Cron" wp_schedule_event

How can I debug problems with WordPress Cron? I think it will trigger when users go to your site but any errors wont be shown to them, as the jobs are run "asynchronously". So how might I debug errors?...
Jiew Meng's user avatar
  • 1,871
25 votes
6 answers
13k views

Running WP Cron on multisite the right way

I have WordPress Multisite with several sites. I set up DISABLE_WP_CRON to true in my wp-config.php. If we set up cron task with wget or curl we have 30 sec rule to execute PHP script. It's so small ...
Kolya Korobochkin's user avatar
19 votes
6 answers
20k views

WP Cron Doesn't Execute When Time Elapses

The goal I want to use wp_schedule_single_event( ) to execute a single event that sends me an e-mail 8 minutes after the user submits a form. The issue The following code is in my functions.php: ...
Mike Madern's user avatar
  • 3,909
18 votes
10 answers
26k views

Delete thousands of cron jobs

I discovered that I have 29,000 cron jobs in my WordPress database from deactivated and deleted plugins. I have tried a number of optimizer plugins but the huge number of cron jobs means I can't ...
Pádraig Ó Beirn's user avatar
17 votes
3 answers
12k views

Check if function called by cron job

I have a function that I only want to run via a cron job. Is there a way I can check that a particular scheduled event is calling this function and not anything else?
urok93's user avatar
  • 3,914
12 votes
4 answers
65k views

Wp_Schedule_Event every day at specific time

I write Following code to run my function every day at 16:20 .. But I guess is the problem in code.. not working Epoch timestamp: 1427488800 3/28/2015 1:10:00 AM if( !wp_next_scheduled( '...
Mortzea's user avatar
  • 186
10 votes
2 answers
7k views

Do WordPress cron jobs slow down page loading?

If a user visits a site and his visit triggers a cron job that is quite intensive, the page load speed will be slower for him right? As I understand the page doesn't wait for the cron job to execute ...
urok93's user avatar
  • 3,914
9 votes
2 answers
10k views

Uncaught Error: Call to undefined function wp_generate_attachment_metadata() @ wp-cron

Devs I have a WP-cronjob running that is supposed to import some pictures and set them as attachments for a specific post. But I'm apparently unable to do so while running it as a WP-cronjob - it ...
Mac's user avatar
  • 313
9 votes
2 answers
7k views

Delete all scheduled events with a particular hook

I have several cron jobs all hooked to the same hook, but each with a different argument (a post ID). It appears wp_clear_scheduled_hook only clears job which match the argument passed with it (or ...
Stephen Harris's user avatar
9 votes
2 answers
1k views

Wordpress cron isn't scheduled on amazon web services

I'm trying to setup a cron to run every hour, it works fine on my local vagrant box, but it doesn't seem to schedule properly on aws(elastic beanstalk). Here's the code: register_activation_hook(...
aabreu's user avatar
  • 221
8 votes
2 answers
2k views

Running WordPress on the Command Line - Turn off Delayed Output?

I'm creating a cron job that runs outside of WordPress. From a development perspective, this makes it really easy to debug and create cleanup scripts or cron jobs, by just running a command like the ...
Alex Cook's user avatar
  • 567
8 votes
3 answers
3k views

Schedule WordPress Auto-Updates to only run during business hours

We've turned on WordPress Auto-Updates (yey!), but, just in case this does break anything, we'd like to only run Auto-Updates during daylight hours (e.g. 09:00 - 17:30). We have the "on init" WP-Cron ...
Darren's user avatar
  • 81
8 votes
1 answer
1k views

Real automated and unattended wordpress upgrade including plugins

I'm looking for a truly automated way to upgrade wordpress and its plugins, something that i could put in the crontab and configure it to run daily. I have several wordpress plugins (>20) and a multi-...
sorin's user avatar
  • 1,113
7 votes
3 answers
4k views

How do I log plugin (cron) actions?

Is there a recommended way to log (failed) cron actions from your plugin? For example, I have a plugin that synchronizes with an external service every hour. I want to log how much was changed, but ...
Jan Fabry's user avatar
  • 30.3k
7 votes
2 answers
2k views

How is WP Cron Locking implemented?

WordPress takes measures to ensure that a cron task doesn't run twice when it should run once, e.g. once every hour when an hourly schedule is given, rather than the occasional twice at the scheduled ...
Tom J Nowell's user avatar
  • 56.4k
6 votes
1 answer
9k views

Better handling of WP-CRON server load abuse

There are multiple reports on how wp-cron is a far from ideal solution because it runs every time a page is loaded, which is unnecessary in most scenarios (one scenario in which it would be necessary ...
Gaia's user avatar
  • 574
5 votes
2 answers
6k views

wp-cron.php - How are WP's Cron transients removed?

I have a Wordpress Network that I am tasked with disabling the WP Cron and replacing it with an Apache Cron. I have set up a PHP script that when called by an Apache Cron will loop through all sites ...
Jonnybojangles's user avatar
5 votes
1 answer
2k views

When does next Cron Job run (time from now)?

I would need to know how much time is left between now and the next time a specifc Cron Job is done. For another answer I built a basic cron inspector plugin which can be found here. Reason I'm ...
kaiser's user avatar
  • 50.2k
5 votes
1 answer
631 views

Get frequency of scheduled event

How do I get the frequency of a scheduled event? I am writing a plugin, that would do something in a user defined schedule. The way I am trying to do this, is creating a custom cron schedule, which ...
budhajeewa's user avatar
4 votes
4 answers
4k views

Running WP Cron on specific local time

The scenario is to run insert_post function every midnight (00:00) of local time. Must run daily on weekday. function add_daily_task(){ if((date('l', time()) != 'Saturday') || (date('l', time()) !...
Ivan Slaughter's user avatar
4 votes
2 answers
14k views

wp_schedule_event not working?

I cannot get a Wordpress cron to trigger. I am trying to run this code to see if I can get an email sent to me hourly. It's taken directly from the Wordpress examples here: http://codex.wordpress.org/...
benedict_w's user avatar
4 votes
1 answer
3k views

Need to execute a cron job

I need a cron job to execute the following url http://www.mywebsite.com/wp-admin/admin.php?page=myvideoblog/mvb_main.php&action=processfeed&updatefeed=67 The problem is that it requires ...
David Garcia's user avatar
4 votes
3 answers
754 views

Refresh external feeds only in cron?

Is there an easy way to ensure that external feeds (via fetch_feed()) are only fetched via cron, and not when a regular user visits the site? This is for performance reasons, I want to minimize the ...
Jan Fabry's user avatar
  • 30.3k
4 votes
2 answers
2k views

run a cron task without obstructing page load?

I have a plugin that lets users upload post attachments via AJAX in the admin area. I later try to push these files to DropBox via their REST API. It almost works. The issue is with WP cron task which,...
montrealist's user avatar
  • 3,044
4 votes
1 answer
2k views

WordPress cron running twice

I have the following code that creates a CSV and then sends an email: function generate_and_send_csv() { // Removed CSV code for ease of reading wp_mail('email@address.com', 'New Data ...
Liam McArthur's user avatar
4 votes
1 answer
777 views

crontab wp-cron.php on multisite path-based network: one for each path? Or just one for the root?

I have a single wordpress with multisite config enabled: define( 'WP_ALLOW_MULTISITE', true ); I want disable internal cron in wp-config.php with: define('DISABLE_WP_CRON', true); My multisite ...
ar099968's user avatar
  • 295
4 votes
1 answer
495 views

Recurring scheduled task help

I'm trying to set up a scheduled task in my Wordpress installation which will (eventually) run a script to send an email once a day with a load of data in. However I can't seem to get a scheduled ...
Probocop's user avatar
  • 219
4 votes
1 answer
501 views

Calling static method in the Widget Class

I have a widget class Xwidget extends WP_Widget{ function cron_addB(){} } I want to run a cron job that calls that function from outside the class function xxx_cron_activation() { ; if ( !...
Freeman's user avatar
  • 143
4 votes
1 answer
142 views

Cron firing my function everytime wp-admin is visited

This is a MU-plugin I'm developing, and I want it to run hourly. Unfortunately, it's running every time I visit any site's wp-admin page. I've used the Debug Bar plugin with the Cron plugin, and it ...
danhgilmore's user avatar
3 votes
2 answers
6k views

Delete posts from a post type automatically via Cron

how can I use Cron to delete posts of a certain post type once they reach a certain limit, like keep maximum 50 posts? The reason is that these posts are being imported automatically periodically, so ...
urok93's user avatar
  • 3,914
3 votes
2 answers
939 views

What would be a PHP command to erase all posts from category X from the last month?

I wish to run a cron job that would permanently erase all the posts belonging to some category from the past X days (say, week). This is probably very basic, but I would appreciate some pointers. ...
Tal Galili's user avatar
  • 1,833
3 votes
2 answers
3k views

What happens when wp_cron is deactivated in Wordpress?

In a Wordpress 3.5.1 the apache log generates the following error related to wp-cron.php: [18/Jun/2013:10:53:21 +0200] "POST /wp-cron.php?doing_wp_cron=1371545601.7393701076507568359375 HTTP/1.0" ...
rfc1484's user avatar
  • 143
3 votes
2 answers
4k views

Transient RSS feeds in wp_options not removed automatically?

I just noticed 55.000 entries(!) in my wp_options table. I had not been there for a while. So I ran: delete from `wp_options` where `option_name` like '_transient_timeout_rss%' delete from `...
edelwater's user avatar
  • 2,574
3 votes
2 answers
3k views

Running wp-cron from CLI

Not sure if my assumption is correct regarding running wp-cron from CLI would be slightly faster than calling it via wget or curl, so either way I'm trying this: /usr/bin/php /var/www/mywebsite.com/...
Nimbuz's user avatar
  • 601
3 votes
1 answer
596 views

How to make wp cron job not fire immediately?

I'm scheduling a job in wp cron: add_action('my_cron_hook', 'my_cron_action'); wp_schedule_event( time(), 'interval1', 'my_cron_hook' ); function my_cron_action(){ //do something } The ...
dimitris's user avatar
3 votes
1 answer
2k views

How Do I Make WordPress Run an Event Every Day?

In a plugin I want to build, it deals with contests. A contest has a date on it. Does WordPress have a feature in it where it can run a piece of code every day without requiring someone to create a ...
Volomike's user avatar
  • 1,805
3 votes
1 answer
1k views

get_posts inside cron

Edited to rewrite my question I'll try to be as clear as possible, as I need to get this resolved quickly. I disabled WordPress' cron, and added a real cron job on my server to call wp-cron.php ...
Shane's user avatar
  • 831
3 votes
1 answer
2k views

get_posts / WP_Query Memory size of 134217728 bytes exhausted

I want to get all post IDs of my product pages. But either the first way or the second way are succesfull... I always get: PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to ...
Jan's user avatar
  • 197
3 votes
1 answer
328 views

Hourly WP schedule, do I need at least 1 visitor hourly?

I am planning to schedule an hourly task from my wp plugin, as I understand these tasks are triggered by visits to the website. So for an hourly task I will need at least one visitor hourly. Does it ...
kyxrus's user avatar
  • 69
3 votes
2 answers
5k views

Initialize WordPress environment to use in a real cron script

I have to run a PHP script through real cron (WP cron being too unreliable). Within that script, I need $wpdb to insert data into WordPress table. But of course $wpdb will not be available as ...
a_fan's user avatar
  • 945
3 votes
2 answers
1k views

Cron jobs for deactivated plugins

Hi I am using a plugin to view the cron jobs that are run by wordpress. I am noticing that there are jobs related to plugins I have deactivated and even deleted. Why is this so and how can I remove ...
urok93's user avatar
  • 3,914
3 votes
1 answer
3k views

Updating WooCommerce variable product stock issue

Soo.. I've created CRON script, that each 1 minute retrieves an actual stock systems data, converts it for Wordpress/Woocommerce database table and updates stock. On database side everything looks ...
richardev's user avatar
  • 161
3 votes
1 answer
759 views

Why?: hundreds of empty files named wp-cron.php?doing_wp_cron.<digit>

In the home directory of the nginx user I have hundreds of empty files named wp-cron.php?doing_wp_cron. So my questions are why...? can I delete them...? . and how do I stop then regenerating? ...
Wayne Theisinger's user avatar
3 votes
1 answer
596 views

Can't access wp_filesystem in cron function

I'm writing a plugin for integrating WP with Visma. It will basically spit out an XML file every third hour using wp cron (going to setup server cron for wp-cron.php on the live site) and save it to ...
Jonathan de Jong's user avatar
3 votes
1 answer
1k views

Cronjob not working as expected - issue with hook?

Today I've tried to write a Wordpress Cronjob. For testing purposes I wrote a function that sends me an email every hour, but it's not working. I've got a plugin called 'Core Control' which shows me ...
Sven's user avatar
  • 371
3 votes
2 answers
583 views

WP CRON runs only the first time

Here is my code function cron_add_weekly( $schedules ) { $schedules['seconds'] = array( 'interval' => 5, 'display' => __( '5 Seconds' ) ); return $schedules; } ...
johnson's user avatar
  • 33
3 votes
2 answers
1k views

Is there any background process that I can run from plugin without depending on page hits on a website without affecting page-load speed?

I am developing a WordPress plugin and wants to run a background task that calls an API and updates database table. Now, the API can only give results for 5 DB entries in one go and for 500 entries in ...
beginner's user avatar
  • 151
3 votes
2 answers
3k views

Multiple wp_schedule_event cron jobs in plugin cause multi-execution

over the last week I have been working on some cron jobs for a real-estate website that has hundreds of updates/deletes and new posts added each day. I am very near the end now and looking to ...
Entrit's user avatar
  • 31
3 votes
1 answer
793 views

WP Cron emails not working

Running wp 3.5.1. I have 2 plugins that work in part. They do everything nice. If I click to send emails, they send the emails. However the scheduled emails are not being sent. The plugins are: ...
utnalove's user avatar

1
2 3 4 5 6