In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to monitor log files in real time under Linux. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
How to view the contents of log files in Linux in real time? There are many utilities that can help users track or monitor changes in files as they are modified or constantly updated.
Use the tail command
Using the tail command is the most basic way to track log files in real time. In particular, if you are on a server with only one terminal and no GUI. This is very helpful.
For example:
Tail / path/to/log/file
Monitoring multiple log files via tail
Use the switch-f to track the log file, which is updated in real time. For example, if you want to track syslog, you can use the following command:
Tail-f / var/log/syslog
You can monitor multiple log files with one command, using:
Tail-f / var/log/syslog / var/log/dmesg
If you want to monitor http or sftp or any server, you can also monitor their respective log files in this command.
Remember, the above command requires administrator privileges.
Use lnav (log file browser)
Lnav Running
Lnav is a great tool that you can use to monitor log files in a more organized way with color-coded information. On Linux systems, it is not installed by default. You can install it with the following command:
Sudo apt install lnav # Ubuntusudo dnf install lnav # Fedora
The good news is, if you don't want to install it, you can download its precompiled executable file directly and run it anywhere. Even from a flash drive. It doesn't need to be set up, and it has many functions. With lnav, you can query log files through SQL, as well as other cool features, which you can find on its official website.
Once installed, you can simply run lnav from the terminal with administrator privileges, which will display all logs in / var/log by default and start real-time monitoring.
Journalctl description of systemd
Most of today's modern Linux distributions use systemd. Systemd provides the basic framework and components for running the Linux operating system. Systemd provides logging services through journalctl to help manage logs for all systemd services. You can also monitor various systemd services and logs in real time with the following command.
Journalctl-f
Here are some specific journalctl commands that can be used in some cases. You can combine these commands with the-f switch above to start real-time monitoring.
For emergency system information, use:
Journalctl-p 0
Displays an error with an explanation:
Journalctl-xb-p 3
Use time control to filter the output:
Journalctl-since "2020-12-04 06:00:00" journalctl-- since "2020-12-03"-- until "2020-12-05 03:00:00" journalctl-- since yesterdayjournalctl-- since 09:00-- until "1 hour ago" Thank you for reading! This is the end of the article on "how to monitor log files in real time under Linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.