Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

max_execution_time is 240 second - exceeded the timeout of 60 seconds

I'm using this package to run my bash:

use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;

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?

like image 651
S.M_Emamian Avatar asked Oct 24 '25 10:10

S.M_Emamian


2 Answers

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 Symfony\Component\Process\Process;

$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.

like image 150
Daniel Costa Avatar answered Oct 26 '25 23:10

Daniel Costa


If you want to disable the setTimeout or setIdleTimeout completely, simply set them as null:

$process->setTimeout(null);
$process->setIdleTimeout(null);
like image 42
Frank Boon Avatar answered Oct 26 '25 22:10

Frank Boon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!