продолжайте запускать процесс / обновление в bash

#bash #process #tail

#bash #процесс #хвост

Вопрос:

Я хочу следить за выводом конкретной команды, скажем ps aux | grep guest .

Я жду, когда это изменится. Есть ли какой-нибудь способ, которым я мог бы сделать что-то вроде tail того, что команда делает с файлом?

Макс

Ответ №1:

Вы ищете:

 watch "ps aux | grep guest"
  

Комментарии:

1. вау. ни за что! как мне указать интервал?

2. @tekknolagi: используйте --interval флаг.

3. @tekknolagi: Вы можете использовать -n seconds . Со страницы руководства: watch runs command repeatedly, displaying its output and errors (the first screenfull). This allows you to watch the program output change over time. By default, the program is run every 2 seconds; use -n or --interval to specify a different interval. Normally, this interval is interpreted as the amout of time between the completion of one run of command and the beginning of the next run. However, with the -p or --precise option, you can make watch attempt to run command every interval seconds.

4. Простой watch ps также отлично работает, если у вас не слишком много процессов (каждый из них можно отслеживать вместе).