0

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 !

1 Answers1

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