Why my custom scheduler is not running?

I'm doing a custom scheduler to do a soft delete to a table and when i upload the package to sugar it doesn't show any error but it's not running. The status is active and there's no last execution. Also, the LBL does not show in the dropdown it's just a blank space. Here's a screenshot:

Here's my code

soft_delete_wsmonitor.php which is the custom scheduler:

<?php

array_push($job_strings, 'soft_delete_wsmonitor');
function soft_delete_wsmonitor()
{
global $db;
$conn = $db->getConection();
$query = "UPDATE wsmon_wsmonitor SET deleted = 1 WHERE date_entered < DATE_SUB(NOW(), INTERVAL 3 MONTH) LIMIT 50";
try {
$conn->executeQuery($query);
}
catch (DBALException $e) {
$GLOBALS['log']->fatal($e->getMessage());
} finally {
$conn->disconnect();
}
return true;
}

es_LA.soft_delete_wsmonitor.php which is the label extension file:

<?php

$mod_strings['LBL_CUSTOM_JOB'] = 'Soft Delete WSMonitor Records';

Parents
  • Hi Itzel,

    There are a few reasons the scheduler might not be working.
    1. Your Cron Job is not configured properly on your server. Please make sure there is an entry in your crontab for running the sugar's crons.
    2. One of the schedulers failed to complete and threw an error. Sometimes sugar will not run the next scheduled jobs in line if one of the previous jobs failed. So make sure all of the jobs are exiting properly with "return true" and handle exceptions and error via sugar logger.
    3. The reason your label isn't working is because the index in your defined label doesn't match with the job name you have created. The index should be LBL_SOFT_DELETE_WSMONITOR not LBL_CUSTOM_JOB
     
    I hope this helps.
Reply
  • Hi Itzel,

    There are a few reasons the scheduler might not be working.
    1. Your Cron Job is not configured properly on your server. Please make sure there is an entry in your crontab for running the sugar's crons.
    2. One of the schedulers failed to complete and threw an error. Sometimes sugar will not run the next scheduled jobs in line if one of the previous jobs failed. So make sure all of the jobs are exiting properly with "return true" and handle exceptions and error via sugar logger.
    3. The reason your label isn't working is because the index in your defined label doesn't match with the job name you have created. The index should be LBL_SOFT_DELETE_WSMONITOR not LBL_CUSTOM_JOB
     
    I hope this helps.
Children
No Data