Comment déboguer WordPress "Cron" wp_schedule_event
-
-
Lisez cette documentation: https://developer.wordpress.org/plugins/cron/hooking-into-the-system-task-scheduler/Read This documentation : https://developer.wordpress.org/plugins/cron/hooking-into-the-system-task-scheduler/
- 1
- 2016-12-06
- Nanhe Kumar
-
Utilisez leplugin [Advanced Cron Manager] (https://wordpress.org/plugins/advanced-cron-manager/)Use [Advanced Cron Manager](https://wordpress.org/plugins/advanced-cron-manager/) plugin
- 0
- 2017-03-06
- Guest
-
4 réponses
- votes
-
- 2011-03-31
Vouspouvezexécuter WP cronmanuellementen appelant:
http://example.com/wp-cron.php?doing_wp_cron
Si vousne voulezpas que le cron automatique s'exécutependant le débogage,ajoutez-le à votrefichier
/wp-config.php
:define('DISABLE_WP_CRON', true);
Si vous êtes dans unenvironnement de développementet que vous souhaitez afficher desinformations de débogage,l'appelermanuellement comme cela vousmontrera votre sortie de débogage.
Vouspouvez également utiliser lafonction error_log intégrée de PHPpour consigner les chaînes demessage dans l'erreurlogpour le débogage.Vous devrez l'utiliser conjointement avec les paramètres WP_DEBUG ,commementionnépar Rarst.
You can run WP cron manually by calling:
http://example.com/wp-cron.php?doing_wp_cron
If you don't want the automatic cron to run while you're debugging, then add this to your
/wp-config.php
file:define('DISABLE_WP_CRON', true);
If you're on a development environment and want to output debug information, calling it manually like that will show you your debug output.
Alternatively you can use PHP's built-in error_log function to log message strings to the error log for debugging. You'd need to use this in conjunction with WP_DEBUG settings, as mentioned by Rarst.
-
Mercipour l'indication avec leparamètre `? Doing_cron`.Thank you for the hint with the `?doing_cron` parameter.
- 0
- 2011-03-31
- rofflox
-
Jepense que cela devrait être `? Doing_wp_cron` au lieu de`? Doing_cron`.I believe it should be `?doing_wp_cron` instead of `?doing_cron`.
- 3
- 2015-04-23
- liviucmg
-
@liviucmg Oui,vous avez raison.J'aifait letweak.@liviucmg Yes, you're right. I've made the tweak.
- 0
- 2015-08-04
- Simon East
-
Leparamètre `? Doing_wp_cron`est-il requis?Voir [Tutoriel de configuration dumanuel EasyCron] (https://www.easycron.com/cron-job-tutorials/how-to-set-up-cron-job-for-wordpress).Is the `?doing_wp_cron` parameter required? See [EasyCron's manual set up tutorial](https://www.easycron.com/cron-job-tutorials/how-to-set-up-cron-job-for-wordpress).
- 1
- 2016-09-03
- AlecRust
-
@gabrielk Leparamètre? doing_cronest-il requis?Qu'est-ce que ça veut dire?@gabrielk Is the ?doing_cron parameter required? what does it mean?
- 0
- 2017-02-23
- jedi
-
- 2011-03-31
Vouspouvez utiliser leplugin Cron-View .Vouspouvez y voir si votretravailest a)enregistréet b) quelleest laprochaine échéance.
Deplus,vouspouvez ajouter unprogrammateurplusbas à votre événement (parexempletoutes les 2minutes)et tester votreméthodeplusfréquemment sur un système local.Utilisez le hook defiltre 'cron_schedules'pourenregistrer denouvelles heures deplanification.Parexemple:
function my_additional_schedules($schedules) { // interval in seconds $schedules['every2min'] = array('interval' => 2*60, 'display' => 'Every two minutes'); return $schedules; } add_filter('cron_schedules', 'my_additional_schedules');
You could use the plugin Cron-View. There you can see if your job is a) registered and b) what the next due time is.
In addition, you could add a lower schedule-timer to your event (e.g. every 2 min) and test your method more frequently on a local system. Use the 'cron_schedules' filter hook to register new schedule times. For example:
function my_additional_schedules($schedules) { // interval in seconds $schedules['every2min'] = array('interval' => 2*60, 'display' => 'Every two minutes'); return $schedules; } add_filter('cron_schedules', 'my_additional_schedules');
-
- 2011-03-31
Vouspouvez (et devriezprobablement danstous les cas,cron ounon) configurer lejournal deserreurs PHPpour capturertoutes leserreurs.
You can (and probably should in any case, cron or not) configure PHP error log to capture all errors.
-
- 2017-07-24
Vouspouvez déboguermanuellement,en créant une actionet enexécutant l'action Cron à l'intérieur.Comme ceci:
add_action( 'init', function() { if ( ! isset( $_GET['the_cron_test'] ) ) { return; } error_reporting( 1 ); do_action( 'this_is_cron_event_hook' ); die(); } );
Eten accédant à l'adresse de votre site Web:
http://example.com?the_cron_test
Cela devrait vousmontrertoutes leserreurs avec latâchepériodique.
Mais celan'a aucun sens de lefairemanuellement.Vouspouvez utiliser leplugin Advanced Cron Manager PRO quifait celapour vousetenregistre également lejournalet d'autres statistiques.
You could debug manually, by creating an action and executing the Cron action inside. Like this:
add_action( 'init', function() { if ( ! isset( $_GET['the_cron_test'] ) ) { return; } error_reporting( 1 ); do_action( 'this_is_cron_event_hook' ); die(); } );
And by going to your website's address:
http://example.com?the_cron_test
This should show you any errors with the cron task.
But it's without any sense doing it manually. You could use Advanced Cron Manager PRO plugin which does this for you and also saves the log and other stats.
Commentpuis-je déboguer desproblèmes avec WordPress Cron?Jepense que cela se déclenchera lorsque les utilisateursiront sur votre site,mais aucuneerreurne leur seramontrée,car lestravaux sontexécutés "demanière asynchrone".Alors,commentpuis-je déboguer leserreurs?
J'utilise
wp schedule event