2012-09-21 72 views
0

我正在使用shell命令將文檔文件轉換爲pdf。每個用戶可以隨時將其文件轉換爲PHP。有多個用戶可以同時訪問我的轉換器來轉換他們的文件嗎?多次訪問shell腳本

我在專用服務器上使用CENTOS。

回答

1

讓我們來定義你的php轉換工具的可能層次。

terminal # user enters commands here, sees output 

     shell # the terminal automatically starts a shell process 
      # so users can type commands and get work done 

      /path/to/your/conversion/tool.php doc1.doc doc1.pdf 
      # here is the user, accessing your script. 
      # one solution to conversions is to allow for 1 input and 1 ouput file 
      # I have done that to keep things simple, your solution may be different 

      phpcode shell("externalconverter", "doc1.doc","doc1.pdf", "/path/to/tmpWrkSpace"?)     
      # again, a guess, your php is asking to execute a external command 
      # and we're passing the arguments 

        "externalconverter" "doc1.doc" "doc1.pdf" tmp="/path/to/tmpWrkSpace" 
        # again, a guess 

所以,這取決於你或exteranlconverter創建靜態的(或者非唯一的)名稱的臨時文件。 也就是說2個用戶使用不同的文件名同時啓動程序,是否創建了具有完全相同名稱的臨時文件?可能不會,但是這種事情發生並且值得提前檢查。

爲了確認您的安全,請使用2個終端窗口設置測試,提前輸入兩個命令,使用專門爲此測試創建的.doc文件並且無關緊要,同時執行兩個命令時間(儘可能快)。你需要一個足夠大的文件(或者在任何情況下)來花費很長時間來處理你確定兩個文件正在被同時處理。

通常,假設Linux/Unix操作系統,大多數程序允許同時運行多個副本。但測試是你最好的防守。

如果這不能回答您的問題,請考慮使用上述提綱編輯您的問題,向我們展示轉換工具中元素的層次結構。 IHD。

IHTH。

+0

+1非常好的方法來模糊的問題。 – chepner