【问题标题】:Script started with drush php-script would not exit after ctrl+c以 drush php-script 开头的脚本在 ctrl+c 后不会退出
【发布时间】:2012-10-23 05:10:11
【问题描述】:

我正在用 drush 运行一个大的 php 脚本。该脚本需要很长时间才能运行 - 可能需要几个小时,我想随时停止它。 这是我正在运行的示例 php 脚本:

$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 脚本。 我怎样才能停止脚本呢?

【问题讨论】:

    标签: drupal drush


    【解决方案1】:

    Drush 有没有这个功能的参数,试试drush help?如果没有……

    然后验证运行的进程是否是 PHP 进程:

    killall -u yourusername php
    

    或任何由 drush 运行的进程。

    我认为这是在这种情况下您可以实现此目的的唯一方法。

    【讨论】:

    • 这确实有效!非常感谢!唯一的事情是我在 Windows 7 上并在 Cygwin 下运行 Drush。进程列表中没有列出任何 php 进程(在 Cygwin 下使用 ps aux),并且 killall 在那里不起作用。所以我不得不在cmd中使用taskkill /F /IM php.exe
    猜你喜欢
    • 1970-01-01
    • 2011-06-29
    • 1970-01-01
    • 2021-12-15
    • 1970-01-01
    • 2017-02-06
    • 1970-01-01
    • 2013-03-20
    • 2018-08-21
    相关资源
    最近更新 更多