31

I'm trying to work which plugin is triggering wp-cron. I know about the code: http://codex.wordpress.org/Function_Reference/wp_get_schedules , but I'd prefer to do something in the sql backend rather than write a plugin.

1
  • 1
    For future readers, there are convenient plugins to view cron schedules like Cron Tasks Viewer.
    – Walf
    May 21, 2018 at 0:01

3 Answers 3

45

Why don't you just create a cron job, make a database dump and look where the info about the cron job is kept? That's what I did. As suspected, WordPress 3.5.1 keeps its cron jobs in the {wp}_options table under the name 'cron'.

SELECT *
FROM `wp_options`
WHERE `option_name` LIKE '%cron%'

Or through functions.php:

$cron_jobs = get_option( 'cron' );
var_dump($cron_jobs);
1
  • 4
    "Why don't you just create a cron job, make a database dump and look where the info about the cron job is kept? " - Because OP didn't know how? Jun 28, 2021 at 10:44
23

You can use the WP-CLI.

From the command line, you can run the following command from the directory of your WordPress installation:

wp cron event list  

It will display a table of the scheduled events, when it's set to run, and how often it's rescheduled. Here is what was returned to me when I ran the command:
enter image description here

https://kinsta.com/knowledgebase/wordpress-cron-job/

3
  • 1
    Thanks, it worked for me, if someone wish to check list of wordpress cron on server then use this wp cron event list Apr 9, 2019 at 5:51
  • 2
    @HemantKumar That's exactly what Shreyl's answer said... Mar 5, 2020 at 19:09
  • 2
    If anyone wants to get the cron list for a multisite then you've to define a site URL like this: wp cron event list --url=http://domain.com/site_slug Nov 29, 2021 at 18:03
22

WordPress has an undocumented function, _get_cron_array(), that returns an array of all currently scheduled tasks. We are going to use a crude but effective method to dump out all the tasks using var_dump(). For ease of use place the following code in the plugin:

echo '<pre>';
print_r( _get_cron_array() );
echo '</pre>';

For more info: https://developer.wordpress.org/plugins/cron/simple-testing/

1
  • It seems that _get_cron_array() basically just calls get_option('cron'). Probably better to do that (as mentioned in the answer marked as correct) than use a function marked private (in its docblock). Dec 20, 2021 at 17:21

Your Answer

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

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