ds261634878 2017-03-20 20:08
浏览 28
已采纳

检测内置PHP服务器的拆解

Is there a way to detect if a running built-in PHP server has been stopped? Either by hitting Ctrl-C or just by closing the terminal window.

I'm using it for a development environment and would like to clean up some files on teardown.

  • 写回答

2条回答 默认 最新

  • dqmdlo9674 2017-03-20 20:36
    关注

    well, i don't know if there are exist in the php built-in server feature to do so,

    but as a work around you may accomplish this using terminal,

    using the ; symbol which is used to separate two commands and in executing the second command after the first command finishes it's execution.

    for example this script will add shut down line to the file status.txt only when you hit CTRL+C -finishing the first command- :

    php -S localhost:8000 ; echo "shut down" >> status.txt
    

    you may create a new php/bash script or whatever to execute specific tasks and execute it after exiting the server -after hitting CTRL+C

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型