php for迴圈指令碼。

來源:互聯網
上載者:User
$dir = "./$time/";
$info = deepScanDir($dir);

for($i=0; $i system("/usr/sbin/php temp.php \($i\).txt output\($i\).txt");
}
deepScanDir是迴圈檔案夾下的所有檔案。
現在這個迴圈一次執行一次這個命令,我想弄一個,迴圈一次執行很多個命令,相當於多進程吧。多謝了!


回複討論(解決方案)

system("/usr/sbin/php temp.php \($i\).txt output\($i\).txt &");
就不會等待完成了

system("/usr/sbin/php temp.php \($i\).txt output\($i\).txt &");
就不會等待完成了



不行啊,還是一個檔案一個檔案讀。不是多個。

一個檔案一個檔案讀 是必然的,但命名執行在後台已經是並行的了
當然也要看命令和程式是否支援並行了

方便加您個QQ我跟您說一下嗎,我弄了快一天了。。

一個檔案一個檔案讀 是必然的,但命名執行在後台已經是並行的了
當然也要看命令和程式是否支援並行了



[fjg@leona html]$ ps aux|grep php
fjg 13997 0.0 0.0 146968 8008 pts/13 S 16:53 0:00 /usr/sbin/php temp.php (0).txt output(0).txt
fjg 16668 0.0 0.0 146972 7948 pts/13 S 16:54 0:00 /usr/sbin/php temp.php (0).txt output(0).txt
fjg 19027 0.0 0.0 146716 7640 pts/13 S 16:54 0:00 /usr/sbin/php temp.php (0).txt output(0).txt
fjg 22115 0.0 0.0 146968 7720 pts/13 S 16:55 0:00 /usr/sbin/php temp.php (0).txt output(0).txt
fjg 28070 0.0 0.0 144860 7324 pts/13 S 16:56 0:00 /usr/sbin/php data.php test.txt
fjg 28075 0.0 0.0 146716 7656 pts/13 S 16:56 0:00 /usr/sbin/php temp.php (0).txt output(0).txt
fjg 28609 0.0 0.0 61152 756 pts/13 S+ 17:11 0:00 grep php

這樣算是多進程了嗎....
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.