0

I have Windows 10 with xampp installed. Let's assume I have a PHP script, containing

set_time_limit(0);
ignore_user_abort(true);

$counter = 0;

while($counter < 60){
    file_put_contents('runtime_log.txt', $counter." \r\n", FILE_APPEND);
    $counter++;
    sleep(1);
}

I can close the browser window and the script will be still writing output to runtime_log.txt If I wanted to check if it's running in the background on Linux, I would use

ps aux | grep php

How to do the same thing on Windows?

EDIT: I have simplified my question, because I can see that it's been misunderstood.

Enri
  • 25
  • 5
  • 1
    Possible duplicate of [How to get the OS on which PHP is running?](https://stackoverflow.com/questions/1482260/how-to-get-the-os-on-which-php-is-running) – Link Sep 04 '17 at 18:39
  • https://superuser.com/questions/18830/is-there-a-command-in-windows-like-ps-aux-in-unix you need command `tasklist` – vadim_hr Sep 04 '17 at 18:40
  • @vadim_hr I have tried to use it, but it doesn't show any php.exe processes. – Enri Sep 04 '17 at 18:55
  • probably process is not php.exe, but apache or similar. what about using this utility https://learn.microsoft.com/en-us/sysinternals/downloads/handle ? you can check if file `runtime_log.txt` is still in use. – vadim_hr Sep 05 '17 at 07:58

2 Answers2

0

Don't put too much effort, just use the constant PHP_OS as also described here: How to get the OS on which PHP is running?

Link
  • 29
  • 5
0

You can't get that information directly from the process list in Windows, because by default Apache is configured to load PHP as a module (a .DLL) so it will not be listed as a different process when it's running (unless PHP is configured to run as CGI, but nowadays that option is not used anymore).

I think that you can search for that using Process explorer, open it and then search (with the binoculars icon) for opened handles for runtime_log.txt, if the file is opened by PHP an open handle should appear for the httpd (Apache) process (this is method I use for finding the program that prevents me from deleting a file).

Note that you probably need to run Process Explorer elevated (as an administrator) since Apache is running as system service.

Alberto Martinez
  • 2,620
  • 4
  • 25
  • 28