Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Close window STOP php script?

Tags:

php

window

I have tried searching for this forever, but unfortunately I could not find the answer. I am calculating a whole lot of Pearson correlations on huge matrixes on my server. I do this by opening example.org/testscript.php.

The script itself will terminate about a 2 days after it has started and will perform many INSERT INTO databases for recommendation purposes.

I was wondering when I closed the window of my browser, whether the PHP script would stop or not. I am assuming not; however I am not a 100% sure.

P.S. I have noticed that in some browsers on some computers I will receive an internal server error (500) when starting the script after about 10 minutes. The script itself however was still running as it was still inserting rows in my database.

On this computer however I have not received such error and therefore I was wondering what would happen when I closed the tab.

like image 559
user1949616 Avatar asked Dec 05 '25 14:12

user1949616


1 Answers

The php script will terminate after reaching the timeout. You can change the timeout: http://php.net/manual/en/function.set-time-limit.php

The browser will however timeout much sooner, if you are not producing any output. The browser timeout is of course browser-specific.

As Dagon suggested, the correct way would be to execute the php script on the server in the background.

like image 51
Alen Oblak Avatar answered Dec 07 '25 03:12

Alen Oblak



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!