Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在通过 Windows 控制台执行 PHP 脚本。我有一些将结果写入文件的结束函数。无论如何,有时我必须中断执行(ctrl + c)并停止脚本。我有兴趣以某种方式将当前进度写入键击和实际 sigterm 之间的文件。这可能吗 ?下次我运行它时,我真的需要能够从最后一点恢复我的脚本执行。谢谢 !
您可以为SIGTERM注册信号处理程序:
function sig_handler($signo) { // Do something } pcntl_signal(SIGTERM, "sig_handler");
然后,您的处理程序应在收到信号时执行。