Jump to content

Using exec() from cron job


jimmyborofan

Recommended Posts

I have a cron job that grabs a list of folders that need processing


These folders are scanned for a particular type of file and then those are processed.


I am trying to get this to run as a parallel process by using exec.

The complication arises when the it is called, it just doesnt seem to call the function.

I use the codeigniter framework with the cli.php found on this very site (thank you whoever wrote that!)

The loop works like this:

    public function loopBatchDir()
    {
    [...]
    begin Loop
    foreach ($batches as $batch)
    {
    exec("php /var/path/to/webroot/cli.php Controller backgroundProcess".$batch['filename'] . " > /dev/null &")

    }
    end Loop
    }

    
    
    public function backgroundProcess()
    {
    /*this is the test section */
    echo "I have been called";
    /*end test section*/
        $batchFile = $this->uri->segment(4);
        $this->batch->insertBatchData()
    
    }


SO when I call backgroundProcess() from the command line the I get the echo and the process executes (when providing a correct parameter

When the loopBatchDir() is called by command line the entire process works fine, but the exec command is completley ignored.

Other Info:  This is on a fresh dedicated server that we have exclusive use of, I have had to make changes to several php settings and I am also wondering if exec is function that has to be turned on in php.ini?

Any help, appreciated.

Jim

Link to comment
https://forums.phpfreaks.com/topic/280029-using-exec-from-cron-job/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.