Cron job hang - how to debug?How do I set up cron job in Magento for Google product feed?Determine origin of...

Why are 150k or 200k jobs considered good when there are 300k+ births a month?

What defenses are there against being summoned by the Gate spell?

What do you call a Matrix-like slowdown and camera movement effect?

What are these boxed doors outside store fronts in New York?

What's the point of deactivating Num Lock on login screens?

Is it important to consider tone, melody, and musical form while writing a song?

What does it mean to describe someone as a butt steak?

Why did the Germans forbid the possession of pet pigeons in Rostov-on-Don in 1941?

Why do falling prices hurt debtors?

Why don't electron-positron collisions release infinite energy?

Why doesn't Newton's third law mean a person bounces back to where they started when they hit the ground?

Is this a crack on the carbon frame?

How is it possible to have an ability score that is less than 3?

Why Is Death Allowed In the Matrix?

Accidentally leaked the solution to an assignment, what to do now? (I'm the prof)

LaTeX closing $ signs makes cursor jump

Is a tag line useful on a cover?

Why "Having chlorophyll without photosynthesis is actually very dangerous" and "like living with a bomb"?

tikz: show 0 at the axis origin

Test whether all array elements are factors of a number

What do three bars across the stem of a note mean?

Why doesn't H₄O²⁺ exist?

Is it possible to do 50 km distance without any previous training?

Prove that NP is closed under karp reduction?



Cron job hang - how to debug?


How do I set up cron job in Magento for Google product feed?Determine origin of mystery cron jobmagento cron job is working or not? how to check?After I installed a new template, some of my cron jobs couldn't be added to schedule tableCron not runningCron job not runningMagento 2 Custom cron job is ignoredTurn on CRON jobs, many months after published webshop. What happens?Magento2 Cron job not runningHow to setup Magento 2.2 cron job?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







2















I have some cronjob that sometime get stuck in running status.



That make me think that for some reason they produce and error but I cannot find any related log. ( the column messages in cron_schedule is empty )



How can I be sure cron execution produce log in case of errors ?

How can I proceed to debug this issue, any advice ?



UPDATE

It looks my question is not clear, so I'm adding some more content ( I am not sure it gonna help because most of the people seem to read the title and guess the question ... )




  • I know how cron works

  • I know how to check if a cronjobs run or not

  • My cronjobs correctly run


The problem is some of the cronjobs do not end.



To be more clear: Mage_Cron_Model_Observer::_processJob()



  $schedule
->setExecutedAt(strftime('%Y-%m-%d %H:%M:%S', time()))
->save();

call_user_func_array($callback, $arguments);

$schedule
->setStatus(Mage_Cron_Model_Schedule::STATUS_SUCCESS)
->setFinishedAt(strftime('%Y-%m-%d %H:%M:%S', time()));


The setStatus is never reached for some cron, that is the problem.



Please avoid give random answer or just the first result google provide ( I know how to use google, I did my research ... )



If the answer is not clear, just let me know.

If you wanna help you are more the welcome if you just want waste my and your time you are not. ( this site is meant for quality answers, it is not a forum where everybody says his opinion ... posting not related answer will not help other people with same issue ... but will just create confusion )










share|improve this question
















bumped to the homepage by Community 1 min ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • You can see the status in the column message of table cron_schedule in the database.

    – Abbas
    Jun 21 '17 at 3:11











  • Try this magento extension github.com/AOEpeople/Aoe_Scheduler. It allows to manage cron jobs.

    – Nicholas Miller
    Jun 21 '17 at 4:53











  • Is this an indexing job? If so, is it possible it being restarted when already running, resulting in a never ending reindex? In my experience, it's either a job that calls exit() preventing other jobs to run (yes, I've seen this in extensions) or jobs that overlap and use temporary tables, overwriting work already in progress.

    – Melvyn
    Jun 21 '17 at 7:50











  • @Abbas came on, really ?

    – Fra
    Jun 21 '17 at 10:38











  • @NicholasMiller I know that extension, is it is not helpful here ... thx

    – Fra
    Jun 21 '17 at 10:39


















2















I have some cronjob that sometime get stuck in running status.



That make me think that for some reason they produce and error but I cannot find any related log. ( the column messages in cron_schedule is empty )



How can I be sure cron execution produce log in case of errors ?

How can I proceed to debug this issue, any advice ?



UPDATE

It looks my question is not clear, so I'm adding some more content ( I am not sure it gonna help because most of the people seem to read the title and guess the question ... )




  • I know how cron works

  • I know how to check if a cronjobs run or not

  • My cronjobs correctly run


The problem is some of the cronjobs do not end.



To be more clear: Mage_Cron_Model_Observer::_processJob()



  $schedule
->setExecutedAt(strftime('%Y-%m-%d %H:%M:%S', time()))
->save();

call_user_func_array($callback, $arguments);

$schedule
->setStatus(Mage_Cron_Model_Schedule::STATUS_SUCCESS)
->setFinishedAt(strftime('%Y-%m-%d %H:%M:%S', time()));


The setStatus is never reached for some cron, that is the problem.



Please avoid give random answer or just the first result google provide ( I know how to use google, I did my research ... )



If the answer is not clear, just let me know.

If you wanna help you are more the welcome if you just want waste my and your time you are not. ( this site is meant for quality answers, it is not a forum where everybody says his opinion ... posting not related answer will not help other people with same issue ... but will just create confusion )










share|improve this question
















bumped to the homepage by Community 1 min ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • You can see the status in the column message of table cron_schedule in the database.

    – Abbas
    Jun 21 '17 at 3:11











  • Try this magento extension github.com/AOEpeople/Aoe_Scheduler. It allows to manage cron jobs.

    – Nicholas Miller
    Jun 21 '17 at 4:53











  • Is this an indexing job? If so, is it possible it being restarted when already running, resulting in a never ending reindex? In my experience, it's either a job that calls exit() preventing other jobs to run (yes, I've seen this in extensions) or jobs that overlap and use temporary tables, overwriting work already in progress.

    – Melvyn
    Jun 21 '17 at 7:50











  • @Abbas came on, really ?

    – Fra
    Jun 21 '17 at 10:38











  • @NicholasMiller I know that extension, is it is not helpful here ... thx

    – Fra
    Jun 21 '17 at 10:39














2












2








2


0






I have some cronjob that sometime get stuck in running status.



That make me think that for some reason they produce and error but I cannot find any related log. ( the column messages in cron_schedule is empty )



How can I be sure cron execution produce log in case of errors ?

How can I proceed to debug this issue, any advice ?



UPDATE

It looks my question is not clear, so I'm adding some more content ( I am not sure it gonna help because most of the people seem to read the title and guess the question ... )




  • I know how cron works

  • I know how to check if a cronjobs run or not

  • My cronjobs correctly run


The problem is some of the cronjobs do not end.



To be more clear: Mage_Cron_Model_Observer::_processJob()



  $schedule
->setExecutedAt(strftime('%Y-%m-%d %H:%M:%S', time()))
->save();

call_user_func_array($callback, $arguments);

$schedule
->setStatus(Mage_Cron_Model_Schedule::STATUS_SUCCESS)
->setFinishedAt(strftime('%Y-%m-%d %H:%M:%S', time()));


The setStatus is never reached for some cron, that is the problem.



Please avoid give random answer or just the first result google provide ( I know how to use google, I did my research ... )



If the answer is not clear, just let me know.

If you wanna help you are more the welcome if you just want waste my and your time you are not. ( this site is meant for quality answers, it is not a forum where everybody says his opinion ... posting not related answer will not help other people with same issue ... but will just create confusion )










share|improve this question
















I have some cronjob that sometime get stuck in running status.



That make me think that for some reason they produce and error but I cannot find any related log. ( the column messages in cron_schedule is empty )



How can I be sure cron execution produce log in case of errors ?

How can I proceed to debug this issue, any advice ?



UPDATE

It looks my question is not clear, so I'm adding some more content ( I am not sure it gonna help because most of the people seem to read the title and guess the question ... )




  • I know how cron works

  • I know how to check if a cronjobs run or not

  • My cronjobs correctly run


The problem is some of the cronjobs do not end.



To be more clear: Mage_Cron_Model_Observer::_processJob()



  $schedule
->setExecutedAt(strftime('%Y-%m-%d %H:%M:%S', time()))
->save();

call_user_func_array($callback, $arguments);

$schedule
->setStatus(Mage_Cron_Model_Schedule::STATUS_SUCCESS)
->setFinishedAt(strftime('%Y-%m-%d %H:%M:%S', time()));


The setStatus is never reached for some cron, that is the problem.



Please avoid give random answer or just the first result google provide ( I know how to use google, I did my research ... )



If the answer is not clear, just let me know.

If you wanna help you are more the welcome if you just want waste my and your time you are not. ( this site is meant for quality answers, it is not a forum where everybody says his opinion ... posting not related answer will not help other people with same issue ... but will just create confusion )







magento-1.9 cron






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jun 21 '17 at 6:59







Fra

















asked Jun 21 '17 at 2:06









FraFra

4,585115094




4,585115094





bumped to the homepage by Community 1 min ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 1 min ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • You can see the status in the column message of table cron_schedule in the database.

    – Abbas
    Jun 21 '17 at 3:11











  • Try this magento extension github.com/AOEpeople/Aoe_Scheduler. It allows to manage cron jobs.

    – Nicholas Miller
    Jun 21 '17 at 4:53











  • Is this an indexing job? If so, is it possible it being restarted when already running, resulting in a never ending reindex? In my experience, it's either a job that calls exit() preventing other jobs to run (yes, I've seen this in extensions) or jobs that overlap and use temporary tables, overwriting work already in progress.

    – Melvyn
    Jun 21 '17 at 7:50











  • @Abbas came on, really ?

    – Fra
    Jun 21 '17 at 10:38











  • @NicholasMiller I know that extension, is it is not helpful here ... thx

    – Fra
    Jun 21 '17 at 10:39



















  • You can see the status in the column message of table cron_schedule in the database.

    – Abbas
    Jun 21 '17 at 3:11











  • Try this magento extension github.com/AOEpeople/Aoe_Scheduler. It allows to manage cron jobs.

    – Nicholas Miller
    Jun 21 '17 at 4:53











  • Is this an indexing job? If so, is it possible it being restarted when already running, resulting in a never ending reindex? In my experience, it's either a job that calls exit() preventing other jobs to run (yes, I've seen this in extensions) or jobs that overlap and use temporary tables, overwriting work already in progress.

    – Melvyn
    Jun 21 '17 at 7:50











  • @Abbas came on, really ?

    – Fra
    Jun 21 '17 at 10:38











  • @NicholasMiller I know that extension, is it is not helpful here ... thx

    – Fra
    Jun 21 '17 at 10:39

















You can see the status in the column message of table cron_schedule in the database.

– Abbas
Jun 21 '17 at 3:11





You can see the status in the column message of table cron_schedule in the database.

– Abbas
Jun 21 '17 at 3:11













Try this magento extension github.com/AOEpeople/Aoe_Scheduler. It allows to manage cron jobs.

– Nicholas Miller
Jun 21 '17 at 4:53





Try this magento extension github.com/AOEpeople/Aoe_Scheduler. It allows to manage cron jobs.

– Nicholas Miller
Jun 21 '17 at 4:53













Is this an indexing job? If so, is it possible it being restarted when already running, resulting in a never ending reindex? In my experience, it's either a job that calls exit() preventing other jobs to run (yes, I've seen this in extensions) or jobs that overlap and use temporary tables, overwriting work already in progress.

– Melvyn
Jun 21 '17 at 7:50





Is this an indexing job? If so, is it possible it being restarted when already running, resulting in a never ending reindex? In my experience, it's either a job that calls exit() preventing other jobs to run (yes, I've seen this in extensions) or jobs that overlap and use temporary tables, overwriting work already in progress.

– Melvyn
Jun 21 '17 at 7:50













@Abbas came on, really ?

– Fra
Jun 21 '17 at 10:38





@Abbas came on, really ?

– Fra
Jun 21 '17 at 10:38













@NicholasMiller I know that extension, is it is not helpful here ... thx

– Fra
Jun 21 '17 at 10:39





@NicholasMiller I know that extension, is it is not helpful here ... thx

– Fra
Jun 21 '17 at 10:39










3 Answers
3






active

oldest

votes


















0














All of the fields should speak for themselves.



Copy and save the following PHP script.



<?php

// Parse magento's local.xml to get db info, if local.xml is found

if (file_exists('app/etc/local.xml')) {

$xml = simplexml_load_file('app/etc/local.xml');

$tblprefix = $xml->global->resources->db->table_prefix;
$dbhost = $xml->global->resources->default_setup->connection->host;
$dbuser = $xml->global->resources->default_setup->connection->username;
$dbpass = $xml->global->resources->default_setup->connection->password;
$dbname = $xml->global->resources->default_setup->connection->dbname;

}

else {
exit('Failed to open app/etc/local.xml');
}

// DB Interaction
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to <a class="HelpLink" onclick="showHelpTip(event, hint_id_7); return false;" href="javascript:void(0)">mysql</a>');
mysql_select_db($dbname);

$result = mysql_query("SELECT * FROM " . $tblprefix . "cron_schedule") or die (mysql_error());


// CSS for NexStyle
echo '
<html>
<head>
<title=Magento Cron <span style='background-color:#CCFF00;'>Status</span>>
<style type="text/css">
html {
width: 100%;
font-family: Helvetica, Arial, sans-serif;
}
body {
background-color:#00AEEF;
color:#FFFFFF;
line-height:1.0em;
font-size: 125%;
}
b {
color: #FFFFFF;
}
table{
border-spacing: 1px;
border-collapse: collapse;
width: 300px;
}
th {
text-align: center;
font-size: 125%;
font-weight: bold;
padding: 5px;
border: 2px solid #FFFFFF;
background: #00AEEF;
color: #FFFFFF;
}
td {
text-align: left;
padding: 4px;
border: 2px solid #FFFFFF;
color: #FFFFFF;
background: #666;
}
</style>
</head>';

// DB info for user to see
echo '
<body>
<a href="http://nexcess.net">
<img src="https://smhttp-nex.nexcesscdn.net/803313/static/images/logoMainR2.gif" width="217" height="38" alt="Nexcess Beyond Hosting"></a>



<b>Table Prefix:</b> ' . $tblprefix . ''
. '<b>DB Host:</b> ' . $dbhost . ''
. '<b>DB User:</b> ' . $dbuser . ''
. '<b>DB Name</b>: ' . $dbname . '</p>';

// Set up <span style="background-color:#CCFF00;">the</span> table
echo "
<table border='1'>
<thread>
<tr>
<th>schedule_id</th>
<th>job_code</th>
<th><span style="background-color:#CCFF00;">status</span></th>
<th>messages</th>
<th>created_at</th>
<th>scheduled_at</th>
<th>executed_at</th>
<th>finished_at</th>
</tr>
</thread>
<tbody>";

// Display <span style="background-color:#CCFF00;">the</span> data from <span style="background-color:#CCFF00;">the</span> query
while ($row = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['schedule_id'] . "</td>";
echo "<td>" . $row['job_code'] . "</td>";
echo "<td>" . $row['<span style="background-color:#CCFF00;">status</span>'] . "</td>";
echo "<td>" . $row['messages'] . "</td>";
echo "<td>" . $row['created_at'] . "</td>";
echo "<td>" . $row['scheduled_at'] . "</td>";
echo "<td>" . $row['executed_at'] . "</td>";
echo "<td>" . $row['finished_at'] . "</td>";
echo "</tr>";
}

// Close table and last few tags
echo "</tbody></table></body></html>";

mysql_close($conn);
?>





share|improve this answer
























  • I can open phpmyadmin if i need to check the cron, this is not the point.

    – Fra
    Jun 21 '17 at 4:47











  • Also when you provide an answer you should give a little of information, if the question is not clear you can always point it out

    – Fra
    Jun 21 '17 at 4:48



















0














I'm sharing my approach because it looks there is nothing better right now:




  1. Disable the system cron for magento


  2. now you can call the cron manually:



    php cron.php -mdefault




Calling the cron from cli should give more info in case of errors not captured by magento.



if you want to test a precise cronjob you may want to temporary alter Mage_Cron_Model_Observer::_generateJobsin order to force this job to always be schedule.



Here an example to force catalog_product_alert



 protected function _generateJobs($jobs, $exists)
{
$scheduleAheadFor = Mage::getStoreConfig(self::XML_PATH_SCHEDULE_AHEAD_FOR)*60;
$schedule = Mage::getModel('cron/schedule');

foreach ($jobs as $jobCode => $jobConfig) {

$cronExpr = null;
if ($jobConfig->schedule->config_path) {
$cronExpr = Mage::getStoreConfig((string)$jobConfig->schedule->config_path);
}
if (empty($cronExpr) && $jobConfig->schedule->cron_expr) {
$cronExpr = (string)$jobConfig->schedule->cron_expr;
}
if (!$cronExpr || $cronExpr == 'always') {
continue;
}
// this force catalog_product_alert to be schedule always
if ($jobCode == 'catalog_product_alert') {
$cronExpr='*/1 * * * *';
}





share|improve this answer



















  • 1





    If you want a specific cron, you can use this one: github.com/netz98/n98-magerun#run-cronjob

    – simonthesorcerer
    Jun 21 '17 at 7:33











  • I will look into n98-magerun but I have some doubt it will be helpful for debugging purposes ..

    – Fra
    Jun 21 '17 at 10:42











  • Don't doubt that for a minute. It's extremely useful, once you know your way around.

    – Melvyn
    Jun 21 '17 at 10:44











  • At least you don't have to temporarily edit the core to run a specific cron job ;) Also, it has some other useful functions

    – simonthesorcerer
    Jun 21 '17 at 10:44



















0














Some basic steps for debugging cron jobs:




  1. Check all your logs (mysql, apache, magento, cron, php, etc..). Look for any errors related to the code that should be running (check timestamps against the expected cron execution time, look for any irregularities).


  2. Follow the instruction here to download the utility. https://github.com/netz98/n98-magerun (TLDR; wget https://files.magerun.net/n98-magerun.phar)


  3. Gather your cron job code. ./n98-magerun.phar sys:cron:list


  4. Trigger your cron job manually ./n98-magerun.phar sys:cron:run cron_job_code



  5. Debug output if cron job runs unsuccessfully



    5A. Add debugging code (logging calls, etc) and manually trigger to determine where in the call stack your code is failing/terminating.




Depending on why its failing you could then assess whether its possible to create a log entry.



Potential configuration related causes of single cron task failure:




  • MySQL Server Has Gone Away


  • PHP Max Execution time reached


  • PHP Memory Limit Exceeded



n98-magerun sys command documentation http://n98-magerun.readthedocs.io/en/latest/commands/sys.html






share|improve this answer
























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "479"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f179984%2fcron-job-hang-how-to-debug%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    All of the fields should speak for themselves.



    Copy and save the following PHP script.



    <?php

    // Parse magento's local.xml to get db info, if local.xml is found

    if (file_exists('app/etc/local.xml')) {

    $xml = simplexml_load_file('app/etc/local.xml');

    $tblprefix = $xml->global->resources->db->table_prefix;
    $dbhost = $xml->global->resources->default_setup->connection->host;
    $dbuser = $xml->global->resources->default_setup->connection->username;
    $dbpass = $xml->global->resources->default_setup->connection->password;
    $dbname = $xml->global->resources->default_setup->connection->dbname;

    }

    else {
    exit('Failed to open app/etc/local.xml');
    }

    // DB Interaction
    $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to <a class="HelpLink" onclick="showHelpTip(event, hint_id_7); return false;" href="javascript:void(0)">mysql</a>');
    mysql_select_db($dbname);

    $result = mysql_query("SELECT * FROM " . $tblprefix . "cron_schedule") or die (mysql_error());


    // CSS for NexStyle
    echo '
    <html>
    <head>
    <title=Magento Cron <span style='background-color:#CCFF00;'>Status</span>>
    <style type="text/css">
    html {
    width: 100%;
    font-family: Helvetica, Arial, sans-serif;
    }
    body {
    background-color:#00AEEF;
    color:#FFFFFF;
    line-height:1.0em;
    font-size: 125%;
    }
    b {
    color: #FFFFFF;
    }
    table{
    border-spacing: 1px;
    border-collapse: collapse;
    width: 300px;
    }
    th {
    text-align: center;
    font-size: 125%;
    font-weight: bold;
    padding: 5px;
    border: 2px solid #FFFFFF;
    background: #00AEEF;
    color: #FFFFFF;
    }
    td {
    text-align: left;
    padding: 4px;
    border: 2px solid #FFFFFF;
    color: #FFFFFF;
    background: #666;
    }
    </style>
    </head>';

    // DB info for user to see
    echo '
    <body>
    <a href="http://nexcess.net">
    <img src="https://smhttp-nex.nexcesscdn.net/803313/static/images/logoMainR2.gif" width="217" height="38" alt="Nexcess Beyond Hosting"></a>



    <b>Table Prefix:</b> ' . $tblprefix . ''
    . '<b>DB Host:</b> ' . $dbhost . ''
    . '<b>DB User:</b> ' . $dbuser . ''
    . '<b>DB Name</b>: ' . $dbname . '</p>';

    // Set up <span style="background-color:#CCFF00;">the</span> table
    echo "
    <table border='1'>
    <thread>
    <tr>
    <th>schedule_id</th>
    <th>job_code</th>
    <th><span style="background-color:#CCFF00;">status</span></th>
    <th>messages</th>
    <th>created_at</th>
    <th>scheduled_at</th>
    <th>executed_at</th>
    <th>finished_at</th>
    </tr>
    </thread>
    <tbody>";

    // Display <span style="background-color:#CCFF00;">the</span> data from <span style="background-color:#CCFF00;">the</span> query
    while ($row = mysql_fetch_array($result)) {
    echo "<tr>";
    echo "<td>" . $row['schedule_id'] . "</td>";
    echo "<td>" . $row['job_code'] . "</td>";
    echo "<td>" . $row['<span style="background-color:#CCFF00;">status</span>'] . "</td>";
    echo "<td>" . $row['messages'] . "</td>";
    echo "<td>" . $row['created_at'] . "</td>";
    echo "<td>" . $row['scheduled_at'] . "</td>";
    echo "<td>" . $row['executed_at'] . "</td>";
    echo "<td>" . $row['finished_at'] . "</td>";
    echo "</tr>";
    }

    // Close table and last few tags
    echo "</tbody></table></body></html>";

    mysql_close($conn);
    ?>





    share|improve this answer
























    • I can open phpmyadmin if i need to check the cron, this is not the point.

      – Fra
      Jun 21 '17 at 4:47











    • Also when you provide an answer you should give a little of information, if the question is not clear you can always point it out

      – Fra
      Jun 21 '17 at 4:48
















    0














    All of the fields should speak for themselves.



    Copy and save the following PHP script.



    <?php

    // Parse magento's local.xml to get db info, if local.xml is found

    if (file_exists('app/etc/local.xml')) {

    $xml = simplexml_load_file('app/etc/local.xml');

    $tblprefix = $xml->global->resources->db->table_prefix;
    $dbhost = $xml->global->resources->default_setup->connection->host;
    $dbuser = $xml->global->resources->default_setup->connection->username;
    $dbpass = $xml->global->resources->default_setup->connection->password;
    $dbname = $xml->global->resources->default_setup->connection->dbname;

    }

    else {
    exit('Failed to open app/etc/local.xml');
    }

    // DB Interaction
    $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to <a class="HelpLink" onclick="showHelpTip(event, hint_id_7); return false;" href="javascript:void(0)">mysql</a>');
    mysql_select_db($dbname);

    $result = mysql_query("SELECT * FROM " . $tblprefix . "cron_schedule") or die (mysql_error());


    // CSS for NexStyle
    echo '
    <html>
    <head>
    <title=Magento Cron <span style='background-color:#CCFF00;'>Status</span>>
    <style type="text/css">
    html {
    width: 100%;
    font-family: Helvetica, Arial, sans-serif;
    }
    body {
    background-color:#00AEEF;
    color:#FFFFFF;
    line-height:1.0em;
    font-size: 125%;
    }
    b {
    color: #FFFFFF;
    }
    table{
    border-spacing: 1px;
    border-collapse: collapse;
    width: 300px;
    }
    th {
    text-align: center;
    font-size: 125%;
    font-weight: bold;
    padding: 5px;
    border: 2px solid #FFFFFF;
    background: #00AEEF;
    color: #FFFFFF;
    }
    td {
    text-align: left;
    padding: 4px;
    border: 2px solid #FFFFFF;
    color: #FFFFFF;
    background: #666;
    }
    </style>
    </head>';

    // DB info for user to see
    echo '
    <body>
    <a href="http://nexcess.net">
    <img src="https://smhttp-nex.nexcesscdn.net/803313/static/images/logoMainR2.gif" width="217" height="38" alt="Nexcess Beyond Hosting"></a>



    <b>Table Prefix:</b> ' . $tblprefix . ''
    . '<b>DB Host:</b> ' . $dbhost . ''
    . '<b>DB User:</b> ' . $dbuser . ''
    . '<b>DB Name</b>: ' . $dbname . '</p>';

    // Set up <span style="background-color:#CCFF00;">the</span> table
    echo "
    <table border='1'>
    <thread>
    <tr>
    <th>schedule_id</th>
    <th>job_code</th>
    <th><span style="background-color:#CCFF00;">status</span></th>
    <th>messages</th>
    <th>created_at</th>
    <th>scheduled_at</th>
    <th>executed_at</th>
    <th>finished_at</th>
    </tr>
    </thread>
    <tbody>";

    // Display <span style="background-color:#CCFF00;">the</span> data from <span style="background-color:#CCFF00;">the</span> query
    while ($row = mysql_fetch_array($result)) {
    echo "<tr>";
    echo "<td>" . $row['schedule_id'] . "</td>";
    echo "<td>" . $row['job_code'] . "</td>";
    echo "<td>" . $row['<span style="background-color:#CCFF00;">status</span>'] . "</td>";
    echo "<td>" . $row['messages'] . "</td>";
    echo "<td>" . $row['created_at'] . "</td>";
    echo "<td>" . $row['scheduled_at'] . "</td>";
    echo "<td>" . $row['executed_at'] . "</td>";
    echo "<td>" . $row['finished_at'] . "</td>";
    echo "</tr>";
    }

    // Close table and last few tags
    echo "</tbody></table></body></html>";

    mysql_close($conn);
    ?>





    share|improve this answer
























    • I can open phpmyadmin if i need to check the cron, this is not the point.

      – Fra
      Jun 21 '17 at 4:47











    • Also when you provide an answer you should give a little of information, if the question is not clear you can always point it out

      – Fra
      Jun 21 '17 at 4:48














    0












    0








    0







    All of the fields should speak for themselves.



    Copy and save the following PHP script.



    <?php

    // Parse magento's local.xml to get db info, if local.xml is found

    if (file_exists('app/etc/local.xml')) {

    $xml = simplexml_load_file('app/etc/local.xml');

    $tblprefix = $xml->global->resources->db->table_prefix;
    $dbhost = $xml->global->resources->default_setup->connection->host;
    $dbuser = $xml->global->resources->default_setup->connection->username;
    $dbpass = $xml->global->resources->default_setup->connection->password;
    $dbname = $xml->global->resources->default_setup->connection->dbname;

    }

    else {
    exit('Failed to open app/etc/local.xml');
    }

    // DB Interaction
    $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to <a class="HelpLink" onclick="showHelpTip(event, hint_id_7); return false;" href="javascript:void(0)">mysql</a>');
    mysql_select_db($dbname);

    $result = mysql_query("SELECT * FROM " . $tblprefix . "cron_schedule") or die (mysql_error());


    // CSS for NexStyle
    echo '
    <html>
    <head>
    <title=Magento Cron <span style='background-color:#CCFF00;'>Status</span>>
    <style type="text/css">
    html {
    width: 100%;
    font-family: Helvetica, Arial, sans-serif;
    }
    body {
    background-color:#00AEEF;
    color:#FFFFFF;
    line-height:1.0em;
    font-size: 125%;
    }
    b {
    color: #FFFFFF;
    }
    table{
    border-spacing: 1px;
    border-collapse: collapse;
    width: 300px;
    }
    th {
    text-align: center;
    font-size: 125%;
    font-weight: bold;
    padding: 5px;
    border: 2px solid #FFFFFF;
    background: #00AEEF;
    color: #FFFFFF;
    }
    td {
    text-align: left;
    padding: 4px;
    border: 2px solid #FFFFFF;
    color: #FFFFFF;
    background: #666;
    }
    </style>
    </head>';

    // DB info for user to see
    echo '
    <body>
    <a href="http://nexcess.net">
    <img src="https://smhttp-nex.nexcesscdn.net/803313/static/images/logoMainR2.gif" width="217" height="38" alt="Nexcess Beyond Hosting"></a>



    <b>Table Prefix:</b> ' . $tblprefix . ''
    . '<b>DB Host:</b> ' . $dbhost . ''
    . '<b>DB User:</b> ' . $dbuser . ''
    . '<b>DB Name</b>: ' . $dbname . '</p>';

    // Set up <span style="background-color:#CCFF00;">the</span> table
    echo "
    <table border='1'>
    <thread>
    <tr>
    <th>schedule_id</th>
    <th>job_code</th>
    <th><span style="background-color:#CCFF00;">status</span></th>
    <th>messages</th>
    <th>created_at</th>
    <th>scheduled_at</th>
    <th>executed_at</th>
    <th>finished_at</th>
    </tr>
    </thread>
    <tbody>";

    // Display <span style="background-color:#CCFF00;">the</span> data from <span style="background-color:#CCFF00;">the</span> query
    while ($row = mysql_fetch_array($result)) {
    echo "<tr>";
    echo "<td>" . $row['schedule_id'] . "</td>";
    echo "<td>" . $row['job_code'] . "</td>";
    echo "<td>" . $row['<span style="background-color:#CCFF00;">status</span>'] . "</td>";
    echo "<td>" . $row['messages'] . "</td>";
    echo "<td>" . $row['created_at'] . "</td>";
    echo "<td>" . $row['scheduled_at'] . "</td>";
    echo "<td>" . $row['executed_at'] . "</td>";
    echo "<td>" . $row['finished_at'] . "</td>";
    echo "</tr>";
    }

    // Close table and last few tags
    echo "</tbody></table></body></html>";

    mysql_close($conn);
    ?>





    share|improve this answer













    All of the fields should speak for themselves.



    Copy and save the following PHP script.



    <?php

    // Parse magento's local.xml to get db info, if local.xml is found

    if (file_exists('app/etc/local.xml')) {

    $xml = simplexml_load_file('app/etc/local.xml');

    $tblprefix = $xml->global->resources->db->table_prefix;
    $dbhost = $xml->global->resources->default_setup->connection->host;
    $dbuser = $xml->global->resources->default_setup->connection->username;
    $dbpass = $xml->global->resources->default_setup->connection->password;
    $dbname = $xml->global->resources->default_setup->connection->dbname;

    }

    else {
    exit('Failed to open app/etc/local.xml');
    }

    // DB Interaction
    $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to <a class="HelpLink" onclick="showHelpTip(event, hint_id_7); return false;" href="javascript:void(0)">mysql</a>');
    mysql_select_db($dbname);

    $result = mysql_query("SELECT * FROM " . $tblprefix . "cron_schedule") or die (mysql_error());


    // CSS for NexStyle
    echo '
    <html>
    <head>
    <title=Magento Cron <span style='background-color:#CCFF00;'>Status</span>>
    <style type="text/css">
    html {
    width: 100%;
    font-family: Helvetica, Arial, sans-serif;
    }
    body {
    background-color:#00AEEF;
    color:#FFFFFF;
    line-height:1.0em;
    font-size: 125%;
    }
    b {
    color: #FFFFFF;
    }
    table{
    border-spacing: 1px;
    border-collapse: collapse;
    width: 300px;
    }
    th {
    text-align: center;
    font-size: 125%;
    font-weight: bold;
    padding: 5px;
    border: 2px solid #FFFFFF;
    background: #00AEEF;
    color: #FFFFFF;
    }
    td {
    text-align: left;
    padding: 4px;
    border: 2px solid #FFFFFF;
    color: #FFFFFF;
    background: #666;
    }
    </style>
    </head>';

    // DB info for user to see
    echo '
    <body>
    <a href="http://nexcess.net">
    <img src="https://smhttp-nex.nexcesscdn.net/803313/static/images/logoMainR2.gif" width="217" height="38" alt="Nexcess Beyond Hosting"></a>



    <b>Table Prefix:</b> ' . $tblprefix . ''
    . '<b>DB Host:</b> ' . $dbhost . ''
    . '<b>DB User:</b> ' . $dbuser . ''
    . '<b>DB Name</b>: ' . $dbname . '</p>';

    // Set up <span style="background-color:#CCFF00;">the</span> table
    echo "
    <table border='1'>
    <thread>
    <tr>
    <th>schedule_id</th>
    <th>job_code</th>
    <th><span style="background-color:#CCFF00;">status</span></th>
    <th>messages</th>
    <th>created_at</th>
    <th>scheduled_at</th>
    <th>executed_at</th>
    <th>finished_at</th>
    </tr>
    </thread>
    <tbody>";

    // Display <span style="background-color:#CCFF00;">the</span> data from <span style="background-color:#CCFF00;">the</span> query
    while ($row = mysql_fetch_array($result)) {
    echo "<tr>";
    echo "<td>" . $row['schedule_id'] . "</td>";
    echo "<td>" . $row['job_code'] . "</td>";
    echo "<td>" . $row['<span style="background-color:#CCFF00;">status</span>'] . "</td>";
    echo "<td>" . $row['messages'] . "</td>";
    echo "<td>" . $row['created_at'] . "</td>";
    echo "<td>" . $row['scheduled_at'] . "</td>";
    echo "<td>" . $row['executed_at'] . "</td>";
    echo "<td>" . $row['finished_at'] . "</td>";
    echo "</tr>";
    }

    // Close table and last few tags
    echo "</tbody></table></body></html>";

    mysql_close($conn);
    ?>






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jun 21 '17 at 3:44









    thismethodthismethod

    123318




    123318













    • I can open phpmyadmin if i need to check the cron, this is not the point.

      – Fra
      Jun 21 '17 at 4:47











    • Also when you provide an answer you should give a little of information, if the question is not clear you can always point it out

      – Fra
      Jun 21 '17 at 4:48



















    • I can open phpmyadmin if i need to check the cron, this is not the point.

      – Fra
      Jun 21 '17 at 4:47











    • Also when you provide an answer you should give a little of information, if the question is not clear you can always point it out

      – Fra
      Jun 21 '17 at 4:48

















    I can open phpmyadmin if i need to check the cron, this is not the point.

    – Fra
    Jun 21 '17 at 4:47





    I can open phpmyadmin if i need to check the cron, this is not the point.

    – Fra
    Jun 21 '17 at 4:47













    Also when you provide an answer you should give a little of information, if the question is not clear you can always point it out

    – Fra
    Jun 21 '17 at 4:48





    Also when you provide an answer you should give a little of information, if the question is not clear you can always point it out

    – Fra
    Jun 21 '17 at 4:48













    0














    I'm sharing my approach because it looks there is nothing better right now:




    1. Disable the system cron for magento


    2. now you can call the cron manually:



      php cron.php -mdefault




    Calling the cron from cli should give more info in case of errors not captured by magento.



    if you want to test a precise cronjob you may want to temporary alter Mage_Cron_Model_Observer::_generateJobsin order to force this job to always be schedule.



    Here an example to force catalog_product_alert



     protected function _generateJobs($jobs, $exists)
    {
    $scheduleAheadFor = Mage::getStoreConfig(self::XML_PATH_SCHEDULE_AHEAD_FOR)*60;
    $schedule = Mage::getModel('cron/schedule');

    foreach ($jobs as $jobCode => $jobConfig) {

    $cronExpr = null;
    if ($jobConfig->schedule->config_path) {
    $cronExpr = Mage::getStoreConfig((string)$jobConfig->schedule->config_path);
    }
    if (empty($cronExpr) && $jobConfig->schedule->cron_expr) {
    $cronExpr = (string)$jobConfig->schedule->cron_expr;
    }
    if (!$cronExpr || $cronExpr == 'always') {
    continue;
    }
    // this force catalog_product_alert to be schedule always
    if ($jobCode == 'catalog_product_alert') {
    $cronExpr='*/1 * * * *';
    }





    share|improve this answer



















    • 1





      If you want a specific cron, you can use this one: github.com/netz98/n98-magerun#run-cronjob

      – simonthesorcerer
      Jun 21 '17 at 7:33











    • I will look into n98-magerun but I have some doubt it will be helpful for debugging purposes ..

      – Fra
      Jun 21 '17 at 10:42











    • Don't doubt that for a minute. It's extremely useful, once you know your way around.

      – Melvyn
      Jun 21 '17 at 10:44











    • At least you don't have to temporarily edit the core to run a specific cron job ;) Also, it has some other useful functions

      – simonthesorcerer
      Jun 21 '17 at 10:44
















    0














    I'm sharing my approach because it looks there is nothing better right now:




    1. Disable the system cron for magento


    2. now you can call the cron manually:



      php cron.php -mdefault




    Calling the cron from cli should give more info in case of errors not captured by magento.



    if you want to test a precise cronjob you may want to temporary alter Mage_Cron_Model_Observer::_generateJobsin order to force this job to always be schedule.



    Here an example to force catalog_product_alert



     protected function _generateJobs($jobs, $exists)
    {
    $scheduleAheadFor = Mage::getStoreConfig(self::XML_PATH_SCHEDULE_AHEAD_FOR)*60;
    $schedule = Mage::getModel('cron/schedule');

    foreach ($jobs as $jobCode => $jobConfig) {

    $cronExpr = null;
    if ($jobConfig->schedule->config_path) {
    $cronExpr = Mage::getStoreConfig((string)$jobConfig->schedule->config_path);
    }
    if (empty($cronExpr) && $jobConfig->schedule->cron_expr) {
    $cronExpr = (string)$jobConfig->schedule->cron_expr;
    }
    if (!$cronExpr || $cronExpr == 'always') {
    continue;
    }
    // this force catalog_product_alert to be schedule always
    if ($jobCode == 'catalog_product_alert') {
    $cronExpr='*/1 * * * *';
    }





    share|improve this answer



















    • 1





      If you want a specific cron, you can use this one: github.com/netz98/n98-magerun#run-cronjob

      – simonthesorcerer
      Jun 21 '17 at 7:33











    • I will look into n98-magerun but I have some doubt it will be helpful for debugging purposes ..

      – Fra
      Jun 21 '17 at 10:42











    • Don't doubt that for a minute. It's extremely useful, once you know your way around.

      – Melvyn
      Jun 21 '17 at 10:44











    • At least you don't have to temporarily edit the core to run a specific cron job ;) Also, it has some other useful functions

      – simonthesorcerer
      Jun 21 '17 at 10:44














    0












    0








    0







    I'm sharing my approach because it looks there is nothing better right now:




    1. Disable the system cron for magento


    2. now you can call the cron manually:



      php cron.php -mdefault




    Calling the cron from cli should give more info in case of errors not captured by magento.



    if you want to test a precise cronjob you may want to temporary alter Mage_Cron_Model_Observer::_generateJobsin order to force this job to always be schedule.



    Here an example to force catalog_product_alert



     protected function _generateJobs($jobs, $exists)
    {
    $scheduleAheadFor = Mage::getStoreConfig(self::XML_PATH_SCHEDULE_AHEAD_FOR)*60;
    $schedule = Mage::getModel('cron/schedule');

    foreach ($jobs as $jobCode => $jobConfig) {

    $cronExpr = null;
    if ($jobConfig->schedule->config_path) {
    $cronExpr = Mage::getStoreConfig((string)$jobConfig->schedule->config_path);
    }
    if (empty($cronExpr) && $jobConfig->schedule->cron_expr) {
    $cronExpr = (string)$jobConfig->schedule->cron_expr;
    }
    if (!$cronExpr || $cronExpr == 'always') {
    continue;
    }
    // this force catalog_product_alert to be schedule always
    if ($jobCode == 'catalog_product_alert') {
    $cronExpr='*/1 * * * *';
    }





    share|improve this answer













    I'm sharing my approach because it looks there is nothing better right now:




    1. Disable the system cron for magento


    2. now you can call the cron manually:



      php cron.php -mdefault




    Calling the cron from cli should give more info in case of errors not captured by magento.



    if you want to test a precise cronjob you may want to temporary alter Mage_Cron_Model_Observer::_generateJobsin order to force this job to always be schedule.



    Here an example to force catalog_product_alert



     protected function _generateJobs($jobs, $exists)
    {
    $scheduleAheadFor = Mage::getStoreConfig(self::XML_PATH_SCHEDULE_AHEAD_FOR)*60;
    $schedule = Mage::getModel('cron/schedule');

    foreach ($jobs as $jobCode => $jobConfig) {

    $cronExpr = null;
    if ($jobConfig->schedule->config_path) {
    $cronExpr = Mage::getStoreConfig((string)$jobConfig->schedule->config_path);
    }
    if (empty($cronExpr) && $jobConfig->schedule->cron_expr) {
    $cronExpr = (string)$jobConfig->schedule->cron_expr;
    }
    if (!$cronExpr || $cronExpr == 'always') {
    continue;
    }
    // this force catalog_product_alert to be schedule always
    if ($jobCode == 'catalog_product_alert') {
    $cronExpr='*/1 * * * *';
    }






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jun 21 '17 at 7:06









    FraFra

    4,585115094




    4,585115094








    • 1





      If you want a specific cron, you can use this one: github.com/netz98/n98-magerun#run-cronjob

      – simonthesorcerer
      Jun 21 '17 at 7:33











    • I will look into n98-magerun but I have some doubt it will be helpful for debugging purposes ..

      – Fra
      Jun 21 '17 at 10:42











    • Don't doubt that for a minute. It's extremely useful, once you know your way around.

      – Melvyn
      Jun 21 '17 at 10:44











    • At least you don't have to temporarily edit the core to run a specific cron job ;) Also, it has some other useful functions

      – simonthesorcerer
      Jun 21 '17 at 10:44














    • 1





      If you want a specific cron, you can use this one: github.com/netz98/n98-magerun#run-cronjob

      – simonthesorcerer
      Jun 21 '17 at 7:33











    • I will look into n98-magerun but I have some doubt it will be helpful for debugging purposes ..

      – Fra
      Jun 21 '17 at 10:42











    • Don't doubt that for a minute. It's extremely useful, once you know your way around.

      – Melvyn
      Jun 21 '17 at 10:44











    • At least you don't have to temporarily edit the core to run a specific cron job ;) Also, it has some other useful functions

      – simonthesorcerer
      Jun 21 '17 at 10:44








    1




    1





    If you want a specific cron, you can use this one: github.com/netz98/n98-magerun#run-cronjob

    – simonthesorcerer
    Jun 21 '17 at 7:33





    If you want a specific cron, you can use this one: github.com/netz98/n98-magerun#run-cronjob

    – simonthesorcerer
    Jun 21 '17 at 7:33













    I will look into n98-magerun but I have some doubt it will be helpful for debugging purposes ..

    – Fra
    Jun 21 '17 at 10:42





    I will look into n98-magerun but I have some doubt it will be helpful for debugging purposes ..

    – Fra
    Jun 21 '17 at 10:42













    Don't doubt that for a minute. It's extremely useful, once you know your way around.

    – Melvyn
    Jun 21 '17 at 10:44





    Don't doubt that for a minute. It's extremely useful, once you know your way around.

    – Melvyn
    Jun 21 '17 at 10:44













    At least you don't have to temporarily edit the core to run a specific cron job ;) Also, it has some other useful functions

    – simonthesorcerer
    Jun 21 '17 at 10:44





    At least you don't have to temporarily edit the core to run a specific cron job ;) Also, it has some other useful functions

    – simonthesorcerer
    Jun 21 '17 at 10:44











    0














    Some basic steps for debugging cron jobs:




    1. Check all your logs (mysql, apache, magento, cron, php, etc..). Look for any errors related to the code that should be running (check timestamps against the expected cron execution time, look for any irregularities).


    2. Follow the instruction here to download the utility. https://github.com/netz98/n98-magerun (TLDR; wget https://files.magerun.net/n98-magerun.phar)


    3. Gather your cron job code. ./n98-magerun.phar sys:cron:list


    4. Trigger your cron job manually ./n98-magerun.phar sys:cron:run cron_job_code



    5. Debug output if cron job runs unsuccessfully



      5A. Add debugging code (logging calls, etc) and manually trigger to determine where in the call stack your code is failing/terminating.




    Depending on why its failing you could then assess whether its possible to create a log entry.



    Potential configuration related causes of single cron task failure:




    • MySQL Server Has Gone Away


    • PHP Max Execution time reached


    • PHP Memory Limit Exceeded



    n98-magerun sys command documentation http://n98-magerun.readthedocs.io/en/latest/commands/sys.html






    share|improve this answer




























      0














      Some basic steps for debugging cron jobs:




      1. Check all your logs (mysql, apache, magento, cron, php, etc..). Look for any errors related to the code that should be running (check timestamps against the expected cron execution time, look for any irregularities).


      2. Follow the instruction here to download the utility. https://github.com/netz98/n98-magerun (TLDR; wget https://files.magerun.net/n98-magerun.phar)


      3. Gather your cron job code. ./n98-magerun.phar sys:cron:list


      4. Trigger your cron job manually ./n98-magerun.phar sys:cron:run cron_job_code



      5. Debug output if cron job runs unsuccessfully



        5A. Add debugging code (logging calls, etc) and manually trigger to determine where in the call stack your code is failing/terminating.




      Depending on why its failing you could then assess whether its possible to create a log entry.



      Potential configuration related causes of single cron task failure:




      • MySQL Server Has Gone Away


      • PHP Max Execution time reached


      • PHP Memory Limit Exceeded



      n98-magerun sys command documentation http://n98-magerun.readthedocs.io/en/latest/commands/sys.html






      share|improve this answer


























        0












        0








        0







        Some basic steps for debugging cron jobs:




        1. Check all your logs (mysql, apache, magento, cron, php, etc..). Look for any errors related to the code that should be running (check timestamps against the expected cron execution time, look for any irregularities).


        2. Follow the instruction here to download the utility. https://github.com/netz98/n98-magerun (TLDR; wget https://files.magerun.net/n98-magerun.phar)


        3. Gather your cron job code. ./n98-magerun.phar sys:cron:list


        4. Trigger your cron job manually ./n98-magerun.phar sys:cron:run cron_job_code



        5. Debug output if cron job runs unsuccessfully



          5A. Add debugging code (logging calls, etc) and manually trigger to determine where in the call stack your code is failing/terminating.




        Depending on why its failing you could then assess whether its possible to create a log entry.



        Potential configuration related causes of single cron task failure:




        • MySQL Server Has Gone Away


        • PHP Max Execution time reached


        • PHP Memory Limit Exceeded



        n98-magerun sys command documentation http://n98-magerun.readthedocs.io/en/latest/commands/sys.html






        share|improve this answer













        Some basic steps for debugging cron jobs:




        1. Check all your logs (mysql, apache, magento, cron, php, etc..). Look for any errors related to the code that should be running (check timestamps against the expected cron execution time, look for any irregularities).


        2. Follow the instruction here to download the utility. https://github.com/netz98/n98-magerun (TLDR; wget https://files.magerun.net/n98-magerun.phar)


        3. Gather your cron job code. ./n98-magerun.phar sys:cron:list


        4. Trigger your cron job manually ./n98-magerun.phar sys:cron:run cron_job_code



        5. Debug output if cron job runs unsuccessfully



          5A. Add debugging code (logging calls, etc) and manually trigger to determine where in the call stack your code is failing/terminating.




        Depending on why its failing you could then assess whether its possible to create a log entry.



        Potential configuration related causes of single cron task failure:




        • MySQL Server Has Gone Away


        • PHP Max Execution time reached


        • PHP Memory Limit Exceeded



        n98-magerun sys command documentation http://n98-magerun.readthedocs.io/en/latest/commands/sys.html







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered May 5 '18 at 5:37









        PepperPepper

        1




        1






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Magento Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f179984%2fcron-job-hang-how-to-debug%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            “%fieldName is a required field.”, in Magento2 REST API Call for GET Method Type The Next...

            How to change City field to a dropdown in Checkout step Magento 2Magento 2 : How to change UI field(s)...

            夢乃愛華...