I am executing a PHP script through Windows Console. I have some ending functions that write results to a file. Anyway, sometimes I have to interrupt the execution (ctrl + c) and halt the script. I am interested in some way to write the current progress to file between keys stroke and actual sigterm. Is this possible ? I'd really need to be able to resume my script execution from last point the next time I run it. Thank you !
Asked
Active
Viewed 159 times
1 Answers
1
You can register a signal handler for SIGTERM:
function sig_handler($signo)
{
// Do something
}
pcntl_signal(SIGTERM, "sig_handler");
Your handler should then be executed when the signal is received.

Mark Lowe
- 1,056
- 8
- 16
-
According to documentation, PCNTL extension is not available on Windows platforms. – Dušan Brejka Aug 04 '15 at 11:28