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. Hvis du administrere en Linux server eller en utvikler det er ganske sannsynlig at du kanskje trenger å se en fil for å sjekke for live oppdateringer til den. 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. Det kan være en loggfil som du ønsker å holde et øye med for å se om eventuelle feil eller meldinger vises, eller det kan være en fil med noen data skrives inn i den. Here's a way you can have that file update itself rather than your having to hit the refresh button constantly. Her er en måte du kan ha denne filen oppdatere seg selv i stedet for å måtte trykke på refresh-knappen hele tiden.
Say you want to monitor the Apache web server log file, /var/log/http/access.log . Si at du vil overvåke Apache web server loggfilen / var / log / http / access.log. Use the following command to get live updates: Bruk følgende kommando for å få live oppdateringer:
# tail -f /var/log/http/access.log # Tail-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. Når du treffer på returtasten skal du se de siste oppføringene i filen (hvis det er noen) og deretter kommandoen vil vente på ytterligere oppdateringer til filen og oppdatere automatisk. One drawback of this command is that you can not scroll up or down using tail. En av ulempene med denne kommandoen er at du ikke kan bla opp eller ned ved hjelp av halen. 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. En annen ulempe med denne kommandoen er at hvis du er overvåking av en fil som blir rullet (filen blir flyttet til en annen fil og en ny, tom fil brukes i stedet for det første), så denne kommandoen vil stoppe oppdateringene. We have a solution for the second problem. Vi har en løsning for det andre problemet. Use the following syntax: Bruk følgende syntaks:
# tail -F /var/log/http/access.log # Tail-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. Den øvre case-F sikrer at selv om filen ruller den vil fortsette å lese fra den nye filen, noe som er ganske nyttig. I usually just use this option regardless of whether I think the file might roll or not. Jeg pleier bare bruke dette alternativet uansett om jeg tror Filen kan rulle eller ikke.























0 Responses 0 Responses
Stay in touch with the conversation, subscribe to the Hold kontakten med samtalen, abonnere på RSS feed for comments on this post RSS feed for kommentarer til dette innlegget . .