Scheduler Job help please

Hello :slight_smile:

i am trying really hard the last few hours, and cant get a custom job executed, am new to suitecrm

i have done exactly whats said here: http://support.sugarcrm.com/02_Documentation/04_Sugar_Developer/Sugar_Developer_Guide_6.5/02_Application_Framework/Job_Queue/01_Schedulers/01_Custom_Schedulers/

and as an action i have added just: $GLOBALS[‘log’]->fatal(‘Running: custom_job’);
i am trying to start with the scheduler with just to make it print a log entry,

please can anyone think why it doesnt work?

(i have done million rebuilds and delete/create the job on the scheduler menu)

these are my files exactly:

root@xxx [/home/xxx/public_html]# ls -la ./custom/Extension/modules/Schedulers/Ext/Language/en_us.custom_job.php 
-rwxr-xr-x 1 xxx xxx 58 Jun  8 18:43 ./custom/Extension/modules/Schedulers/Ext/Language/en_us.custom_job.php*

root@xxx [/home/xxx/public_html]# cat ./custom/Extension/modules/Schedulers/Ext/Language/en_us.custom_job.php 
<?php

    $mod_strings['LBL_CUSTOM_JOB'] = 'Custom Job';


root@xxx [/home/xxx/public_html]# ls -la ./custom/Extension/modules/Schedulers/Ext/ScheduledTasks/custom_job.php
-rwxr-xr-x 1 xxx xxx 158 Jun  8 19:35 ./custom/Extension/modules/Schedulers/Ext/ScheduledTasks/custom_job.php*
root@xxx [/home/xxx/public_html]# cat ./custom/Extension/modules/Schedulers/Ext/ScheduledTasks/custom_job.php
<?php

    array_push($job_strings, 'custom_job');
    function custom_job()
    {
	$GLOBALS['log']->fatal('Running: custom_job');
        return true;
    }

root@xxx [/home/xxx/public_html]# crontab -u xxx -l
* * * * * cd /home/xxxx/public_html; php -f cron.php > /dev/null 2>&1 

The installation is on Cpanel with the latest SuiteCRM installed through Softaculous.

Thanks in advance.

If you want to test whether the cron executes or not. keep the $GLOBALS->fatal() on the first line of function.

  • Make sure you are not writing on .ext.php files
  • perform quick repair and rebuild
  • Make sure the cron job is active
  • Set the execution to as often as possible.
  • go to cron.php on root folder and comment the lines looks like below

$sapi_type = php_sapi_name();
if (substr($sapi_type, 0, 3) != ‘cli’) {
sugar_die(“cron.php is CLI only.”);
}

1 Like

Thank you VERY MUCH! i was going crazy, i have noticed this message “cron.php is CLI only.” when i tried to run cron from shell using runuser, and then i have enabled shell access to the user and the message disappeared but didn’t worked though.

Does anyone has an explanation on why is this happening?

I really appreciated thank you again!

After finding the root cause thanks to urdhvatech i have googled and it seems that the problem exists probably because of jail shells cpanel uses.
I found a cleaner (in my opinion) solution i have replaced php command on the cronjob with php-cli, after this you dont have to comment out the 4 lines on cron.php

more specificaly i have changed this:

* * * * * cd /home/xxxx/public_html; php -f cron.php > /dev/null 2>&1

with this:

* * * * * cd /home/xxxx/public_html; php-cli -f cron.php > /dev/null 2>&1

Glad that it worked :slight_smile: