public function watch($command, $interval = 500)
    {
        $count = 0;
        $activeTime = time();
        $maxTime = (int)$this->config['max_watch_time'];
        $intervalUs = $interval * 1000;

        //echo "watch command: $command, refresh interval: {$interval}ms\n";

        while (true) {
            $count++;
            $result = $this->command($command);

            if (0 === strpos($result, 'ERR')) {
                echo "$result\n";
                echo "error command: $command. ";
                break;
            }

            // clear screen before output
            echo "\033[2JThe {$count} times watch {$command} result(refresh interval: {$interval}ms):\n{$result}\n";

            if ($maxTime > 0 && time() - $activeTime >= $maxTime) {
                echo 'watch time end. ';
                break;
            }

            usleep($intervalUs);
        }

        echo "Quit\n";
    }
public function watch($command, $interval = 500)
    {
        $count = 0;
        $activeTime = time();
        $maxTime = (int)$this->config['max_watch_time'];
        $intervalUs = $interval * 1000;

        //echo "watch command: $command, refresh interval: {$interval}ms\n";

        while (true) {
            $count++;
            $result = $this->command($command);

            if (0 === strpos($result, 'ERR')) {
                echo "$result\n";
                echo "error command: $command. ";
                break;
            }

            // clear screen before output
            echo "\033[2JThe {$count} times watch {$command} result(refresh interval: {$interval}ms):\n{$result}\n";

            if ($maxTime > 0 && time() - $activeTime >= $maxTime) {
                echo 'watch time end. ';
                break;
            }

            usleep($intervalUs);
        }

        echo "Quit\n";
    }
public function watch ( $ command , $ interval = 500 ) { $ count = 0 ; $ activeTime = time ( ) ; $ maxTime = ( int ) $ this -> config [ 'max_watch_time' ] ; $ intervalUs = $ interval * 1000 ; //echo "watch command: $command, refresh interval: {$interval}ms\n"; while ( true ) { $ count ++ ; $ result = $ this -> command ( $ command ) ; if ( 0 === strpos ( $ result , 'ERR' ) ) { echo "$result\n" ; echo "error command: $command. " ; break ; } // clear screen before output echo "\033[2JThe {$count} times watch {$command} result(refresh interval: {$interval}ms):\n{$result}\n" ; if ( $ maxTime > 0 && time ( ) - $ activeTime >= $ maxTime ) { echo 'watch time end. ' ; break ; } usleep ( $ intervalUs ) ; } echo "Quit\n" ; }
watch a command
@param  string $command
@param  integer $interval (ms)
watch a command