function execute($job,$async=TRUE) {
        if (!isset($this->jobs[$job]))
            user_error(sprintf(self::E_NotFound,$job),E_USER_ERROR);
        $f3=\Base::instance();
        if (is_string($func=$this->jobs[$job][0]))
            $func=$f3->grab($func);
        if (!is_callable($func))
            user_error(sprintf(self::E_Callable,$job),E_USER_ERROR);
        if ($async && isset($this->binary)) {
            // PHP docs: If a program is started with this function, in order for it to continue running in the background,
            // the output of the program must be redirected to a file or another output stream.
            // Failing to do so will cause PHP to hang until the execution of the program ends.
            $dir=dirname($this->script);
            $file=basename($this->script);
            if (!preg_match($this->windows?'/^[A-Z]:\\\\/i':'/^\//',$dir))
                $dir=getcwd().'/'.$dir;
            if ($this->windows) {
                pclose(popen(sprintf('start /b "cron" "%s" "%s\\%s" "/cron/%s"',$this->binary,$dir,$file,$job),'r'));
            } else {
                exec(sprintf('cd "%s" && %s %s /cron/%s >/dev/null 2>/dev/null &',$dir,$this->binary,$file,$job));
            }
            return FALSE;
        }
        $start=microtime(TRUE);
        call_user_func_array($func,array($f3));
        if ($this->log) {
            $log=new Log('cron.log');
            $log->write(sprintf(self::L_Execution,$job,microtime(TRUE)-$start));
        }
        return TRUE;
    }
function execute($job,$async=TRUE) {
        if (!isset($this->jobs[$job]))
            user_error(sprintf(self::E_NotFound,$job),E_USER_ERROR);
        $f3=\Base::instance();
        if (is_string($func=$this->jobs[$job][0]))
            $func=$f3->grab($func);
        if (!is_callable($func))
            user_error(sprintf(self::E_Callable,$job),E_USER_ERROR);
        if ($async && isset($this->binary)) {
            // PHP docs: If a program is started with this function, in order for it to continue running in the background,
            // the output of the program must be redirected to a file or another output stream.
            // Failing to do so will cause PHP to hang until the execution of the program ends.
            $dir=dirname($this->script);
            $file=basename($this->script);
            if (!preg_match($this->windows?'/^[A-Z]:\\\\/i':'/^\//',$dir))
                $dir=getcwd().'/'.$dir;
            if ($this->windows) {
                pclose(popen(sprintf('start /b "cron" "%s" "%s\\%s" "/cron/%s"',$this->binary,$dir,$file,$job),'r'));
            } else {
                exec(sprintf('cd "%s" && %s %s /cron/%s >/dev/null 2>/dev/null &',$dir,$this->binary,$file,$job));
            }
            return FALSE;
        }
        $start=microtime(TRUE);
        call_user_func_array($func,array($f3));
        if ($this->log) {
            $log=new Log('cron.log');
            $log->write(sprintf(self::L_Execution,$job,microtime(TRUE)-$start));
        }
        return TRUE;
    }
function execute ( $ job , $ async = TRUE ) { if ( ! isset ( $ this -> jobs [ $ job ] ) ) user_error ( sprintf ( self :: E_NotFound , $ job ) , E_USER_ERROR ) ; $ f3 = \ Base :: instance ( ) ; if ( is_string ( $ func = $ this -> jobs [ $ job ] [ 0 ] ) ) $ func = $ f3 -> grab ( $ func ) ; if ( ! is_callable ( $ func ) ) user_error ( sprintf ( self :: E_Callable , $ job ) , E_USER_ERROR ) ; if ( $ async && isset ( $ this -> binary ) ) { // PHP docs: If a program is started with this function, in order for it to continue running in the background, // the output of the program must be redirected to a file or another output stream. // Failing to do so will cause PHP to hang until the execution of the program ends. $ dir = dirname ( $ this -> script ) ; $ file = basename ( $ this -> script ) ; if ( ! preg_match ( $ this -> windows ? '/^[A-Z]:\\\\/i' : '/^\//' , $ dir ) ) $ dir = getcwd ( ) . '/' . $ dir ; if ( $ this -> windows ) { pclose ( popen ( sprintf ( 'start /b "cron" "%s" "%s\\%s" "/cron/%s"' , $ this -> binary , $ dir , $ file , $ job ) , 'r' ) ) ; } else { exec ( sprintf ( 'cd "%s" && %s %s /cron/%s >/dev/null 2>/dev/null &' , $ dir , $ this -> binary , $ file , $ job ) ) ; } return FALSE ; } $ start = microtime ( TRUE ) ; call_user_func_array ( $ func , array ( $ f3 ) ) ; if ( $ this -> log ) { $ log = new Log ( 'cron.log' ) ; $ log -> write ( sprintf ( self :: L_Execution , $ job , microtime ( TRUE ) - $ start ) ) ; } return TRUE ; }
Execute a job
@param string $job
@param bool $async
@return bool TRUE = job has been executed / FALSE = job has been delegated to a background process
Execute a job