skip to Main Content

I’m using this package to run my bash:

use SymfonyComponentProcessProcess;
use SymfonyComponentProcessExceptionProcessFailedException;

I got this error when I want to run my bash inside laravel:

The process ***/my.sh exceeded the timeout of 60 seconds.

$process = new Process('sh ***/my.sh');
       $process->run();

       // executes after the command finishes
       if (!$process->isSuccessful()) {
          throw new ProcessFailedException($process);
       }

my max_execution_time inside phpinfo function is 240. I restarted my server.
my safe_mode is off. I used this function :

set_time_limit(0);

above my code, but after 60 seconds I got the same error message.
my .htdaccess is 240 seconds.

any idea?

2

Answers


  1. The Process class has a timeout of its own, according to Process docs:

    By default processes have a timeout of 60 seconds, but you can change it passing a different timeout (in seconds) to the setTimeout() method:

    use SymfonyComponentProcessProcess;
    
    $process = new Process('sh ***/my.sh');
    $process->setTimeout(240);
    $process->run();
    

    You should check the idleTimetout as well, if the process may take a long time without outputing any data:

    $process->setIdleTimeout(240);
    

    The docs doesn’t say anything about using 0 as no limit.

    Login or Signup to reply.
  2. If you want to disable the setTimeout or setIdleTimeout completely, simply set them as null:

    $process->setTimeout(null);
    $process->setIdleTimeout(null);
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search