2012-11-02 33 views
4

我正在运行一个带有drush的大php脚本。该脚本需要很长时间才能运行 - 可能需要几个小时,并且我希望在需要时停止它。 下面是一个例子PHP脚本我运行:以ctrl + c结尾的以脚本开头的dr脚本不会退出

$iter = 1; 
while($iter <= 50){ 
    echo "iteration no ". $iter ."\n"; 
    $iter++; 
    sleep(1); 
} 

这是我与运行它的命令:

$ drush php-script userstest.php 

当我按下CTRL + C,在drush命令停止,但php脚本继续运行。 下面是它的外观:

$ drush php-script userstest.php 
iteration no 1 
iteration no 2 
iteration no 3 


$ iteration no 4 
iteration no 5 
iteration no 6 
iteration no 7 
^C 

$ iteration no 8 
iteration no 9 
iteration no 10 
iteration no 11 
^C 

$ iteration no 12 
iteration no 13 
iteration no 14 
iteration no 15 

而且如此下去,直到PHP脚本,它实际上完成。 我怎样才能停止脚本?

回答

1

有Drush没有参数的功能,请尝试drush help?如果不是......

验证是否正在运行的进程那么PHP程序:

killall -u yourusername php 

或任何过程由drush运行。

我认为这是你在这种情况下可以达到这个目的的唯一方法。

+0

这实际上工作!非常感谢! 唯一的是我在Windows 7上运行Cygwin下的Drush。进程列表中没有列出任何php进程(在Cygwin下使用ps aux),killall在那里不起作用。所以我不得不在cmd中使用taskkill/F/IM php.exe – jetpackpony