How to view live updates in a file under Linux Ako zobraziť žiť aktualizácie v súbore pod Linuxom

by Sukrit Dhandhania on June 30, 2009 používateľa Sukrit Dhandhania dňa 30.júna 2009

Linux

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. Máte-li spravovať server Linux alebo autor, je celkom pravdepodobné, že budete potrebovať sledovať súbor na kontrolu žiť aktualizované údaje. 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. Dalo by sa log súbor, ktorý chcete strážiť, či chyby alebo správy sa zobrazí, alebo to môže byť len súbor s niektorými údajmi vpísaný. Here's a way you can have that file update itself rather than your having to hit the refresh button constantly. Tu je spôsob, ako môžete mať tento súbor aktualizovať sám skôr ako by ste museli zasiahnuť tlačidlo obnoviť neustále.

Say you want to monitor the Apache web server log file, /var/log/http/access.log . Povedzme, že chcete sledovať webový server Apache log súbor / var / log / http / access.log. Use the following command to get live updates: Zadajte nasledujúci príkaz, aby si žiť aktualizácia:

# tail -f /var/log/http/access.log # Chvost-f / var / log / 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. Ak stlačíte klávesu Enter, mali by ste vidieť v posledných niekoľkých položiek v súbore (ak existujú) a potom príkaz bude čakať na ďalšiu aktualizáciu a súbor sa automaticky aktualizujú. One drawback of this command is that you can not scroll up or down using tail. Nevýhodou tohto príkazu je, že nemôžete pohybovať nahor alebo nadol pomocou chvosta. 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. Podstatnou nevýhodou tohto príkazu je, že ak ste monitorovanie súboru, ktorý sa za horúca (súbor dostane presunúť do iného súboru a nový prázdny súbor sa používa miesto prvý), potom tento príkaz zastaví aktualizácie. We have a solution for the second problem. Máme riešenie pre druhý problém. Use the following syntax: Použite nasledujúcu syntax:

# tail -F /var/log/http/access.log # Chvost-F / var / log / 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. Veľkými písmenami-F zaisťuje, že aj keď súbor úloha bude pokračovať v čítaní z nového súboru, čo je celkom užitočné. I usually just use this option regardless of whether I think the file might roll or not. Obvykle stačí použiť túto možnosť, bez ohľadu na to, či si myslím, že súbor by mohol úloha, alebo nie.

Related Posts: Súvisiace zmeny:
  • How to backup your Windows Live Contacts Ako zálohovať Windows Live Kontakty
  • How to customize Windows Live Messenger (remove ads, add/remove buttons etc) Ako si prispôsobiť program Windows Live Messenger (odstránenie reklám, pridať / odobrať tlačidlá, atď)
  • 5 Great Web Comics 5 Veľké Web Comics
  • Simplehelp Updates Simplehelp Aktualizácia
  • How to securely clean up data on a hard disk on Linux Ako bezpečne vyčistiť dáta na pevnom disku v systéme Linux
  • Get Simple Help tutorials just like this one in your email inbox every day - for free! Get Help jednoduchá cvičenie, rovnako ako to vo vašej e-mailovej schránky každý deň - zadarmo! Just enter your email address below: Stačí zadať e-mailovú adresu:

    You can always opt out of this email subscription at any time. Vždy sa môžete odhlásiť z tohto e-mailu predplatného kedykoľvek.

    { 0 comments… (0 comments ... add one now pridať jednu teraz } )

    Leave a Comment Zanechať komentár

    You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> Môžete použiť tieto HTML tagy a atribúty: href = "" <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> del datetime <em> <i> <q Cite=""> <strike> <strong>