Score:0

How do you debug a cronjob that's not working?

cn flag
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

$_SERVER['SERVER_SOFTWARE'] = 'Apache';
$_SERVER['HTTP_USER_AGENT'] = 'PHP';
$_SERVER['PHP_SELF'] = '/wp/wp-admin/admin-ajax.php';

require_once(__DIR__ . '/../misc/autoload.php');

define('WP_ADMIN', 1);

print_r("before");
require_once(__DIR__ . '/../public/wp-load.php');
require_once(__DIR__ . '/../public/wp-includes/rewrite.php');
require_once(__DIR__ . '/../public/wp-admin/includes/file.php');
require_once(__DIR__ . '/../public/wp-admin/includes/misc.php');
require_once(__DIR__ . '/../public/wp-admin/includes/plugin.php');
print_r("after");

Using some cronjobs in my wp site, and I need to run this block of code, but the code runs without any error, but the code just stops running before "after" gets printed. It's not outputting any error.

I get a warning:

Warning: Cannot modify header information - headers already sent by (output started at /home/alpha/version/ver/v4.3.11/cake.com/scripts/run-resource.php:2) in /home/alpha/version/ver/v4.3.11/cake.com/vendor/cakeauto/phplibs/hg/wordpress/Bootstrap.php on line 150

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

This bit of code doesn't seem to display any error.

us flag
You need to isolate which one of the includes stops execution by adding more debug prints. Once you find the file where execution stops, look into that file. You might want to add `define('WP_DEBUG', true)` so that WP knows to output debug.
djdomi avatar
za flag
and basically its php so php needs to be in front of the file
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.