10/30/2023 0 Comments Grep tailTo show only webpages can be problematic especially if there is no common extension for the files being served, and some might end with / whereas other might end with. Tail -f /var/log/apache/myvirtualhost.log | grep robots.txt jpgĪnd to match a specific file, for example the robots.txt file if perhaps you are looking out for when a search engine bot hits the site: Tail -f /var/log/apache/myvirtualhost.log | grep. If you only want to watch for requests for a particular file type, or even a particular file then use the same concept as grepping for the IP address. If you want to exclude requests from your own IP address but show everything else this can be useful: Viewing everything excluding a specific IP addressĪdding the -v flag to grep excludes the pattern. 192.168.206.10 etc and that dots will match any character not just the period divider if this is a concern then escape the dots with \ and put the IP address in brackets with a space after the last digit in the IP address like this: Note that the above example would also match e.g. This can be useful to only show results from your own requests. To filter the results to only show requests for a specific IP address (in this example 192.168.206.1) pipe the output from tail through grep like so: Tail can be combined with grep to pattern match. Viewing everything from a specific IP address The -f flag is what makes the tail command output additional data as it is appended to the log. Tail -f /var/log/apache/myvirtualhost.log as additional requests are made to the web server. If the log file to view is at /var/log/apache/myvirtualhost.log the first command below will show the last few lines from the file and then continue to echo to the command line as new lines are entered into the log file i.e.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |