У меня есть процесс, который записывает вывод в log.txt. Если я хочу видеть состояние процесса в режиме реального времени, есть ли способ отобразить этот вывод на стандартный вывод вместо открытия журнала в текстовом редакторе и его постоянной перезагрузки?

3 ответа3

7

Для действительно простого решения в Терминале:

% tail -f log_file.log

Из основного файла хвоста (т.е. man tail):

 -f      The -f option causes tail to not stop when end of file is reached,
         but rather to wait for additional data to be appended to the input.
         The -f option is ignored if the standard input is a pipe, but not if
         it is a FIFO.

 -F      The -F option implies the -f option, but tail will also check to see
         if the file being followed has been renamed or rotated.  The file is
         closed and reopened when tail detects that the filename being read
         from has a new inode number.  The -F option is ignored if reading
         from standard input rather than a file.
2

используйте tail -f чтобы отобразить конец файла, и "следуйте" за ним по мере его роста.

2

Использование:

tail -f log.txt

или в другом вкусе:

watch tail log.txt

Всё ещё ищете ответ? Посмотрите другие вопросы с метками .