Windows蝙蝠检查,如果PHP脚本runnin

我使用蝙蝠在win2003调度程序上运行php。 有没有办法检查进程,看看文件是否仍在运行。

你的批处理文件如何:(伪代码,因为它已经有一段时间了)

: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 

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

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

老实说,我不知道这是不是最好的解决办法。

试用Sysinternals Process Utilities。

http://technet.microsoft.com/en-us/sysinternals/bb896682

pslist实用程序正是你所需要的(给定一个PID告诉它是否正在运行设置一个env变量)

问候

PS:与pslist我建议也评估pskill实用程序