AnsweredAssumed Answered

Cron job not working

Question asked by PS PS on Dec 11, 2014
Latest reply on Dec 12, 2014 by Jeff Bickart
Hello,
I have setup a cronjob in my sugar instance. Steps I have followed are given below.

1. Created a .bat file with contents
cd  path\to\sugar_instance
path\to\php.exe -c path\to\php.ini -f cron.php

2. Create a new Scheduled Task through Start -> Control Panel -> Scheduled Tasks -> Add Scheduled Task And set this task to run everyday at 12 noon.

3. Add following code to the file "custom\modules\Schedulers\_AddJobsHere.php"
$job_strings[] = 'MyCustomJob';
function MyCustomJob(){    
require_once("include/SugarPHPMailer.php");
$email=new SugarPHPMailer();
$email->Subject = "Test email";
$email->prepForOutbound();
$email->setMailerForSystem();
$email->Body = "This is test email....using scheduler"; 
$email->From = "From Name";
$email->FromName = "From Name";
$email->AddAddress('test@example.com');
$email->Send(); 
}

4. And added $mod_strings['LBL_MYCUSTOMJOB'] = 'Test Cron Job Email';
to the file custom\modules\Schedulers\language\en_us.lang.php

5. Then create a new scheduler job from sugar instance admin using this job and set it to run on same time as cron job i.e. 12 noon.
  
I tested this by accessing cron.php from browser, it works fine & I m getting mail. But when I run the same job from control panel, I get error in sugar log as
Job 6e6454c5-da09-765c-0bd4-548985e51433 (Test Cron Job Email) failed in CRON run

I have searched a lot for this issue, but nothing had worked for me. Can anyone guide me for this? Plz this is urgent.

Outcomes