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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.