Monitor website logs under Linux command line

  
 

The following content is a way to use linux as a friend of the website. Although there are many tools in N for analyzing access logs such as apache and nginx. However, any kind of efficient and flexible ^_^ without linux built-in commands. For example: When your graphical system is not working (hacking?!), it is especially important to have some scripts for monitoring and analyzing logs. The following code can monitor the most recent visitor log, which is quite useful.

1. Real-time filtering logs

Use the tail -f command to view the most recent additions to the log files. However, there will be some trouble in the actual application, you will find that a lot of content is output to fill the entire screen. It is necessary to format these contents ^_^. The script is as follows:
# Need to save the script, $COLUMNS variable will be valid #Note: -n10 means to display the last 10 lines of content, you can modify deny="`tput bold; tput setaf 1`" #亮Red high="`tput bold; tput setaf 3`" #亮黄norm="`tput sgr0`"tail "$@" -s.1 -f access_log

Copyright © Windows knowledge All Rights Reserved