2011-05-10 69 views
4

我使用蝙蝠在win2003调度程序上运行一个PHP。有没有办法检查进程并查看文件是否仍在运行。Windows蝙蝠检查,如果PHP脚本runnin

+0

在这里你可能会发现一些选项:http://stackoverflow.com/questions/162291/how-to-check-if-a-process-is-running-via-a-batch-script – 2011-05-10 09:59:47

回答

0

在您的计划任务的.php文件中:使用getmypid()获取PHP进程的ID(PID)并将其保存到文件中。

下次调用.php文件时,请使用$tasks = shell_exec('tasklist.exe');来获取所有活动进程的列表,然后读取先前保存的PID并查找它。

老实说,我不知道这是否是最好的解决方案。

+0

这只对24至48小时;初始加载数据 – David 2011-05-10 01:59:32

+0

调用tasklist.exe没有输出任何东西 – David 2011-05-10 02:44:03

1

谈谈你的批处理文件是这样的:(伪代码,因为它已经有一段时间)

:makerandom 
make som random var, microtime, whatever, we call it %x% 
check if file exist, if it does, goto makerandom 
call the script with %x% as argument 
:check 
if file exist %x% goto check 
:done 
在PHP脚本

create the file specified by the argument 
... script here ... 
delete the file