douxiajia6720 2012-09-25 23:16
浏览 232
已采纳

从CLI调用时,PHP脚本何时停止执行?

I basically have a cron job calling one script every minute. Script immediately stops, if previous script is still running (checks previous script's activity time).

So I made a bug, and the script went in to an infinite loop (I know it was called from by cron atleast one time). I created a fix and uploaded it to the server, but I'm still wondering:

  1. How long will the bugged script run?
  2. How can I know if it is still running?
  3. What does terminate a script and why?

The script just echoes out the same text over and over again.

P.S. PHP's max execution time within the script is set to 0 (infinite) and I don't have a direct access to the server, only FTP.

  • 写回答

2条回答 默认 最新

  • douchu2823 2013-03-02 16:38
    关注

    How can I know if it is still running?

    Just set up a new cron job, but have the cron command be a something that helps you debug: a useful one would be

    ps -af | grep php > /some/path/to/mylogfile.txt
    

    the ps command lists info on running processes. with those flags, part of the output will be the original linux command that started the process, and so we can grep the line and look for php because the origional command was probably something like:

    php myscript.php
    

    the output is redirected to mylogfile.txt for you to manually read after the cron job runs.

    the process id should be part of the output. you can then use the kill command on that process id, again by just entering the command as a fake cron job.

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

报告相同问题?

悬赏问题

  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配