Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens if you edit a php script while an instance of it is running?

Tags:

php

apache

When you overwrite a php file on a server (say, via SFTP) while it is being processed somewhere (perhaps it's a script that takes several seconds to compelete) does it cancel the currently running script or does that finish out even after the overwrite occurs? I suppose I'm asking: does apache load a php script into memory before executing it (and does it hold on to that in memory for the duration of execution)?

like image 860
celwell Avatar asked May 22 '13 18:05

celwell


People also ask

Can you edit PHP file?

A PHP file is a plain text file, so you can open it in any text editor like VI, Notepad, or Sublime Text. For beginners, tools like Notepad++ should do, since they'll just be running small snippets of code.

Does a PHP script runs on the client or the server?

That is, PHP is a server side language - it runs on the server and its interaction with the client is limited to sending it a web page.

How do I stop a PHP script from running in the background?

If you started it in background use ps aux | grep time. php to get PID. Then just kill PID . If process started in foreground, use to interrupt it.

Can a PHP script run forever?

Whenever a PHP application rebuilds MySQL indexes, the process may run for a long time. Generally, allowing a PHP script to run forever is not desirable.


2 Answers

does apache load a php script into memory before executing it (and does it hold on to that in memory for the duration of execution)?

Yes.

like image 179
Andy Lester Avatar answered Oct 05 '22 23:10

Andy Lester


Nothing at all. The script has already been loaded into memory in its compiled state - no matter how much time it takes, the web server won't load the new file unless you refresh the page.

like image 36
rath Avatar answered Oct 05 '22 23:10

rath