簡體   English   中英

Windows Bat檢查php腳本是否運行

[英]Windows Bat check if php script 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實用程序

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM