E1Tips Qucik Tip

Monitor a Log File While It Is Being Written To Using The PowerShell Tail Parameter

Read Time:39 Sec

E1Tips Qucik Tip

Recently, I had a client with a process that was out of control. The logs kept getting too large, too quickly and I wasn’t able to read it with Notepad++. I know that there are many other large text file readers, but I wanted to be able to monitor log as it grew. I was on a Windows Server so this was a perfect opportunity to use the PowerShell Get-Content -Tail & -Wait parameters.

Get-Content .\example.log -Tail 5 –Wait

The -Tail 5 portion does exactly what it sounds like it does… grabs the last 5 lines of text.

The -Wait parameter displays the next lines as they are added to the file.

This came in really handy for me and I hope it does for you too.

Author

Stewart Schatz

Career: Principal CNC Consultant for Syntax Systems Limited specializing Oracle JD Edwards EnterpriseOne and the technology that supports it. Side Hustle: Owner/Operator of E1Tips.com Location: Lancaster, PA USA  What I like to do: Invest in Family, Explore Technology, Lead Teams, Share Knowledge/Experience, Hunt, Hike, etc.

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Quick_Tip_Linux Previous post The Easiest Way To Truncate the Oracle Database listener.log On A Linux Server
Quick_Tip_Linux Next post Quick Tip: How To Set Environment Variables On Linux