public function run()
    {

        try {
            // register shutdown handler
            register_shutdown_function(array(&$this, "shutdown"));

            // store the actual directory
            $actualDir = getcwd();

            // load the node data with the command information
            $executeNode = $this->jobNode->getExecute();

            // try to load the script from the configuration
            if ($script = $executeNode->getScript()) {
                // change the working directory
                if ($execDir = $executeNode->getDirectory()) {
                    chdir($execDir);
                }

                // check if the configured script is a file
                if (is_file($script) && is_executable($script)) {
                    // initialize the exec params
                    $output = array();
                    $returnVar = 0;

                    // execute the script on the command line
                    exec($executeNode, $output, $returnVar);

                    // restore the old directory
                    if ($execDir && $actualDir) {
                        chdir($actualDir);
                    }

                    // query whether the script has been executed or not
                    if ($returnVar !== 0) {
                        throw new \Exception(implode(PHP_EOL, $output));
                    } else {
                        error_log(implode(PHP_EOL, $output));
                    }

                } else {
                    throw new \Exception(sprintf('Script %s is not a file or not executable', $script));
                }

            } else {
                throw new \Exception(sprintf('Can\t find a script configured in job', $this->jobNode->getName()));
            }

        } catch (\Exception $e) {
            // restore the old directory
            chdir($actualDir);
            // log the exception
            error_log($e->__toString());
        }
    }
public function run()
    {

        try {
            // register shutdown handler
            register_shutdown_function(array(&$this, "shutdown"));

            // store the actual directory
            $actualDir = getcwd();

            // load the node data with the command information
            $executeNode = $this->jobNode->getExecute();

            // try to load the script from the configuration
            if ($script = $executeNode->getScript()) {
                // change the working directory
                if ($execDir = $executeNode->getDirectory()) {
                    chdir($execDir);
                }

                // check if the configured script is a file
                if (is_file($script) && is_executable($script)) {
                    // initialize the exec params
                    $output = array();
                    $returnVar = 0;

                    // execute the script on the command line
                    exec($executeNode, $output, $returnVar);

                    // restore the old directory
                    if ($execDir && $actualDir) {
                        chdir($actualDir);
                    }

                    // query whether the script has been executed or not
                    if ($returnVar !== 0) {
                        throw new \Exception(implode(PHP_EOL, $output));
                    } else {
                        error_log(implode(PHP_EOL, $output));
                    }

                } else {
                    throw new \Exception(sprintf('Script %s is not a file or not executable', $script));
                }

            } else {
                throw new \Exception(sprintf('Can\t find a script configured in job', $this->jobNode->getName()));
            }

        } catch (\Exception $e) {
            // restore the old directory
            chdir($actualDir);
            // log the exception
            error_log($e->__toString());
        }
    }
public function run ( ) { try { // register shutdown handler register_shutdown_function ( array ( & $ this , "shutdown" ) ) ; // store the actual directory $ actualDir = getcwd ( ) ; // load the node data with the command information $ executeNode = $ this -> jobNode -> getExecute ( ) ; // try to load the script from the configuration if ( $ script = $ executeNode -> getScript ( ) ) { // change the working directory if ( $ execDir = $ executeNode -> getDirectory ( ) ) { chdir ( $ execDir ) ; } // check if the configured script is a file if ( is_file ( $ script ) && is_executable ( $ script ) ) { // initialize the exec params $ output = array ( ) ; $ returnVar = 0 ; // execute the script on the command line exec ( $ executeNode , $ output , $ returnVar ) ; // restore the old directory if ( $ execDir && $ actualDir ) { chdir ( $ actualDir ) ; } // query whether the script has been executed or not if ( $ returnVar !== 0 ) { throw new \ Exception ( implode ( PHP_EOL , $ output ) ) ; } else { error_log ( implode ( PHP_EOL , $ output ) ) ; } } else { throw new \ Exception ( sprintf ( 'Script %s is not a file or not executable' , $ script ) ) ; } } else { throw new \ Exception ( sprintf ( 'Can\t find a script configured in job' , $ this -> jobNode -> getName ( ) ) ) ; } } catch ( \ Exception $ e ) { // restore the old directory chdir ( $ actualDir ) ; // log the exception error_log ( $ e -> __toString ( ) ) ; } }
Main method that executes the CRON job in a separate thread.

@return void
Main method that executes the CRON job in a separate thread .