If you administer a Linux server or are a developer it is quite likely that you might need to watch a file to check for live updates to it. Якщо адміністрування серверів Linux або розробників, цілком імовірно, що вам може знадобитися, щоб побачити файлу для перевірки оновлень жити до нього. It could be a log file which you want to keep an eye on to see if any errors or messages appear, or it could just be a file with some data written into it. Це може бути лог файл, який ви хочете стежити, щоб побачити якщо будь-які помилки або з'являються повідомлення, або він може бути просто файл з даними, записаними в неї. Here's a way you can have that file update itself rather than your having to hit the refresh button constantly. Ось як ви можете мати файл оновити себе, а не того, щоб ваш хіт кнопку "Обновити" постійно.
Say you want to monitor the Apache web server log file, /var/log/http/access.log . Припустимо, ви хочете відслідковувати роботу сервера Apache Web Log файл / VAR / вхід / HTTP / access.log. Use the following command to get live updates: Використовуйте наступну команду, щоб жити оновлення:
# tail -f /var/log/http/access.log # Хвостом-F / VAR / вхід / HTTP / access.log
When you hit the Return key you should see the last few entries in the file (if there are any) and then the command will wait for further updates to the file and update automatically. Коли ви натиснете К.еШгп ви повинні побачити останні кілька записів у файл (якщо такі є), а потім команду чекатиме подальших оновлень і оновлювати автоматично. One drawback of this command is that you can not scroll up or down using tail. Одним з недоліків цієї команди є те, що ви не можете прокручувати вгору або вниз за допомогою хвоста. Another drawback of this command is that if you are monitoring a file that gets rolled (the file gets moved to another file and a new blank file is used instead of the first one), then this command will stop the updates. Ще один недолік цієї команди є те, що, якщо ви стежите файл запускається на прокат, що (файл переноситься на інший файл і новий порожній файл використовується замість першого), то ця команда буде зупинити оновлень. We have a solution for the second problem. У нас є рішення по другому проблеми. Use the following syntax: Використовуйте наступний синтаксис:
# tail -F /var/log/http/access.log # Хвостом-F / VAR / вхід / HTTP / access.log
The upper case -F ensures that even if the file rolls it will continue reading from the new file, which is quite useful. Верхньому регістрі-F гарантує, що навіть якщо файл рулонах вона буде продовжувати читання з нового файлу, який є досить корисним. I usually just use this option regardless of whether I think the file might roll or not. Я зазвичай просто використовувати цю опцію, незалежно від того, я думаю, що файл може рол чи ні.























{ 0 comments… (0 коментарів ... add one now Додати одну картину } )
Leave a Comment Залишити коментар