Scheduler job doesn't execute my php changes

Hi,

I work with sugar pro 7.6 and I want to execute a custom job which checks the status of the contracts and does something.

I correctly setup my batch file (following the documentation instructions) for the execution of the scheduled job and the file is executed each minute.

I have created a file at this location C:\wamp\www\sugarcrm\custom\Extension\modules\Schedulers\Ext\ScheduledTasks\rinnovo_contratto.php with this lines

 

array_push($job_strings, 'rinnovo_contratto');
function rinnovo_contratto()
{
error_log("Start job",0);
$today = date("Y-m-d");
error_log("Date range start:".$today,0);
return true;
}

I have created a scheduler that execute rinnovo_contratto.php and in the detailview of the scheduler I can see a lot of execution of the job.

The problem is that, when I want to change the code in this php file and I want to test it, I can't do this. If I add some lines of codes nothing happens. I try to delete the cache, make a quick rebuild and rebuild the scheduler but nothing change.

There' s no errors in the log files that can help me to find a possible problem.

Or sugar executes the old job, or it doesn't execute the file.

Can you help me? I can't lose all this time for each update of my code.

Best regards 

Stefano

Parents
  • Thanks to all for the answers,

    I try and retry to rebuild and repair Sugar but nothing happens, this is the situation of my custom file and the file generated by sugar:

    C:\wamp\www\sugarcrm\custom\modules\Schedulers\Ext\ScheduledTasks\scheduledtasks.ext.php

    //Merged from custom/Extension/modules/Schedulers/Ext/ScheduledTasks/rinnovo_contratto.php


    array_push($job_strings, 'rinnovo_contratto');
    function rinnovo_contratto()
    {
    error_log("INIZIO: assegnamento azienda con contratto in scadenza al team rinnovi",0);

    $today = date("Y-m-d");
    $threeMonthsLater = new DateTime("+2 months");
    $threeMonthsLater->format("Y-m-d");

    error_log("Date range start:".$today,0);
    error_log("Date range end:".$threeMonthsLater,0);

    //trovo tutti i contratti firmati con data di scadenza nei prossimi due mesi
    $sugarQuery = new SugarQuery();
    $sugarQuery->select(array('id', 'name'));
    $contractBean = BeanFactory::newBean('Contracts');
    $sugarQuery->from($contractBean, array('team_security' => false));
    $sugarQuery->where()
    ->equals('status', 'Firmato')
    ->dateBetween('end_date',array($today,$threeMonthsLater));
    $result = $sugarQuery->execute();

    error_log("LUNGHEZZA RESULT: ".count($result));

    return true;
    }



    C:\wamp\www\sugarcrm\custom\modules\Schedulers\Ext\ScheduledTasks\scheduledtasks.ext.php

    <?php
    array_push($job_strings, 'rinnovo_contratto');
    function rinnovo_contratto()
    {
        $GLOBALS['log']->fatal("Controllo i contratti in scadenza nei prossimi due mesi");

        $today = date("Y-m-d");
        $threeMonthsLater = new DateTime("+2 months");
        $threeMonthsLater->format("Y-m-d");

        $GLOBALS['log']->fatal("Oggi:".$today);

        //trovo tutti i contratti firmati con data di scadenza nei prossimi due mesi
       /* $sugarQuery = new SugarQuery();
        $sugarQuery->select(array('id', 'name'));
        $contractBean = BeanFactory::newBean('Contracts');
        $sugarQuery->from($contractBean, array('team_security' => false));
        $sugarQuery->where()
            ->equals('status', 'Firmato')
            ->dateBetween('end_date',array($today,$threeMonthsLater));
        $result = $sugarQuery->execute();

        error_log("LUNGHEZZA RESULT: ".count($result));*/

        return true;
    }


    Why is the scheduledtasks.ext.php not updated?

    The job doesn't write on the sugarcrm.log but there's a sequence of this error:

    09/06/16 07:54:59 [10248][1][FATAL] Unable to get server status: Elastica\Exception\ClientException
    09/06/16 07:54:59 [10248][1][FATAL] FTS Server is down, postponing the job for full index.

    but I think that this is due to the other scheduled jobs which they fail for some reasons.

    any suggestions? Best regards

    Stefano

Reply
  • Thanks to all for the answers,

    I try and retry to rebuild and repair Sugar but nothing happens, this is the situation of my custom file and the file generated by sugar:

    C:\wamp\www\sugarcrm\custom\modules\Schedulers\Ext\ScheduledTasks\scheduledtasks.ext.php

    //Merged from custom/Extension/modules/Schedulers/Ext/ScheduledTasks/rinnovo_contratto.php


    array_push($job_strings, 'rinnovo_contratto');
    function rinnovo_contratto()
    {
    error_log("INIZIO: assegnamento azienda con contratto in scadenza al team rinnovi",0);

    $today = date("Y-m-d");
    $threeMonthsLater = new DateTime("+2 months");
    $threeMonthsLater->format("Y-m-d");

    error_log("Date range start:".$today,0);
    error_log("Date range end:".$threeMonthsLater,0);

    //trovo tutti i contratti firmati con data di scadenza nei prossimi due mesi
    $sugarQuery = new SugarQuery();
    $sugarQuery->select(array('id', 'name'));
    $contractBean = BeanFactory::newBean('Contracts');
    $sugarQuery->from($contractBean, array('team_security' => false));
    $sugarQuery->where()
    ->equals('status', 'Firmato')
    ->dateBetween('end_date',array($today,$threeMonthsLater));
    $result = $sugarQuery->execute();

    error_log("LUNGHEZZA RESULT: ".count($result));

    return true;
    }



    C:\wamp\www\sugarcrm\custom\modules\Schedulers\Ext\ScheduledTasks\scheduledtasks.ext.php

    <?php
    array_push($job_strings, 'rinnovo_contratto');
    function rinnovo_contratto()
    {
        $GLOBALS['log']->fatal("Controllo i contratti in scadenza nei prossimi due mesi");

        $today = date("Y-m-d");
        $threeMonthsLater = new DateTime("+2 months");
        $threeMonthsLater->format("Y-m-d");

        $GLOBALS['log']->fatal("Oggi:".$today);

        //trovo tutti i contratti firmati con data di scadenza nei prossimi due mesi
       /* $sugarQuery = new SugarQuery();
        $sugarQuery->select(array('id', 'name'));
        $contractBean = BeanFactory::newBean('Contracts');
        $sugarQuery->from($contractBean, array('team_security' => false));
        $sugarQuery->where()
            ->equals('status', 'Firmato')
            ->dateBetween('end_date',array($today,$threeMonthsLater));
        $result = $sugarQuery->execute();

        error_log("LUNGHEZZA RESULT: ".count($result));*/

        return true;
    }


    Why is the scheduledtasks.ext.php not updated?

    The job doesn't write on the sugarcrm.log but there's a sequence of this error:

    09/06/16 07:54:59 [10248][1][FATAL] Unable to get server status: Elastica\Exception\ClientException
    09/06/16 07:54:59 [10248][1][FATAL] FTS Server is down, postponing the job for full index.

    but I think that this is due to the other scheduled jobs which they fail for some reasons.

    any suggestions? Best regards

    Stefano

Children
No Data