Linux Read Log File Real Time Tail Doesn't Work
How can I see the content of a log file in real fourth dimension in Linux? Well in that location are a lot of utilities out there that can help a user to output the content of a file while the file is changing or continuously updating. Some of the nearly known and heavily used utility to display a file content in existent time in Linux is the tail command (manage files effectively).
Read Also: 4 Adept Open Source Log Monitoring and Direction Tools for Linux
1. tail Command – Monitor Logs in Existent Time
Every bit said, tail command is the most mutual solution to display a log file in real time. Notwithstanding, the control to display the file has two versions, as illustrated in the below examples.
In the start example the command tail needs the -f
argument to follow the content of a file.
$ sudo tail -f /var/log/apache2/access.log
The second version of the command is actually a command itself: tailf. Y'all won't need to use the -f
switch because the command is born with the -f
argument.
$ sudo tailf /var/log/apache2/access.log
Usually, the log files are rotated often on a Linux server by the logrotate utility. To watch log files that get rotated on a daily base of operations you can use the -F
flag to tail command.
Read Also: How to Manage System Logs (Configure, Rotate and Import Into Database) in Linux
The tail -F
will continue track if new log file being created and will start following the new file instead of the sometime file.
$ sudo tail -F /var/log/apache2/access.log
All the same, by default, tail command will display the last 10 lines of a file. For case, if yous want to watch in existent time only the last ii lines of the log file, use the -n
file combined with the -f
flag, as shown in the below example.
$ sudo tail -n2 -f /var/log/apache2/access.log
two. Multitail Command – Monitor Multiple Log Files in Existent Fourth dimension
Another interesting control to display log files in real fourth dimension is multitail command. The name of the command implies that multitail utility tin can monitor and keep track of multiple files in real time. Multitail also lets you navigate back and forth in the monitored file.
To install mulitail utility in Debian and RedHat based systems outcome the beneath command.
$ sudo apt install multitail [On Debian & Ubuntu] $ sudo yum install multitail [On RedHat & CentOS] $ sudo dnf install multitail [On Fedora 22+ version]
To display the output of two log file simultaneous, execute the command equally shown in the beneath example.
$ sudo multitail /var/log/apache2/access.log /var/log/apache2/error.log
3. lnav Control – Monitor Multiple Log Files in Real Time
Another interesting command, similar to multitail command is the lnav command. Lnav utility can also watch and follow multiple files and display their content in existent time.
To install lnav utility in Debian and RedHat based Linux distributions by issuing the beneath command.
$ sudo apt install lnav [On Debian & Ubuntu] $ sudo yum install lnav [On RedHat & CentOS] $ sudo dnf install lnav [On Fedora 22+ version]
Watch the content of two log files simultaneously by issuing the control every bit shown in the below example.
$ sudo lnav /var/log/apache2/access.log /var/log/apache2/error.log
iv. less Command – Display Real Time Output of Log Files
Finally, you tin brandish the live output of a file with less command if you lot type Shift+F
.
As with tail utility, pressing Shift+F
in a opened file in less will start following the end of the file. Alternatively, you can likewise start less with less +F
flag to enter to live watching of the file.
$ sudo less +F /var/log/apache2/access.log
That's It! You may read these following articles on Log monitoring and management.
- Manage Files Finer using head, tail and true cat Commands in Linux
- How to Setup and Manage Log Rotation Using Logrotate in Linux
- Petiti – An Open Source Log Analysis Tool for Linux SysAdmins
- How to Query Inspect Logs Using 'ausearch' Tool on CentOS/RHEL
- Manage Log Messages Nether Systemd Using Journalctl [Comprehensive Guide]
In this commodity, we showed how to sentinel data being appended in log files in real-time on the terminal in Linux. You lot can ask any questions or share your thoughts concerning this guide via the annotate class below.
If Yous Appreciate What We Practise Here On TecMint, You Should Consider:
TecMint is the fastest growing and most trusted community site for whatever kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.
If you like what you are reading, delight consider buying u.s. a coffee ( or 2 ) as a token of appreciation.
We are thankful for your never ending support.
hernandezfartandence.blogspot.com
Source: https://www.tecmint.com/watch-or-monitor-linux-log-files-in-real-time/
0 Response to "Linux Read Log File Real Time Tail Doesn't Work"
Post a Comment