我正在使用蝙蝠在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 告诉它是否正在运行设置环境变量)
问候
PS:使用pslist,我建议也评估pskill实用程序