AnsweredAssumed Answered

Help troubleshooting a custom job

Question asked by Nate Nate on Apr 16, 2015
I created a custom job (Sugar Pro 7.5) called "custom_job," and while I see it being invoked, I don't see any output in the log. I see the following,

           
Thu Apr 16 15:50:26 2015 [82180][1][DEBUG] ----->SchedulersJob calling function: custom_job
Thu Apr 16 15:50:26 2015 [82180][1][INFO] Resolving job 17114dba-f4c2-0829-f8f8-552fbe74523f as success: 
Thu Apr 16 15:50:26 2015 [82180][1][INFO] Entered operation status: updating_relationships
Thu Apr 16 15:50:26 2015 [82180][1][INFO] Left operation status: updating_relationships
Thu Apr 16 15:50:26 2015 [82180][1][DEBUG] Hook called: SchedulersJobs::before_save
Thu Apr 16 15:50:26 2015 [82180][1][DEPRECATED] SugarBean.php: preprocess_fields_on_save() is deprecated
Thu Apr 16 15:50:26 2015 [82180][1][INFO] Query:UPDATE job_queue
                                        SET assigned_user_id='1',name='My custom',date_modified='2015-04-16 13:50:25',scheduler_id='8ababe85-5213-82e1-d235-552ed9455924',execute_time='2015-04-16 13:50:25',status='done',resolution='success',target='function::custom_job',requeue=0,job_delay=0,client='CRON9e570d6a6f812b196dd8f9e42f2aa54a:82180'
Here's the code:
<?php
array_push($job_strings, 'custom_job');
function custom_job()
{
    $GLOBALS['log']->debug(" -------------- Starting job --------------!!!!");
    $accounts = new Accounts();
    $accounts_array = $accounts->retrieve_by_string(array('name' => 'Nate Reed'));
    $account  = $accounts_array[0];
    $account->tps_c = 2;
    $account->save();
    print "Updated account.";
    //logic here
    //return true for completed
    return true;
}

Is it failing on the first line of the function? Is $GLOBALS['log'] a valid way to reference the global log file? Can I assume it's set when this function is called? 

I've set the log level to "debug" in the admin panel.

Outcomes