Skip to main content

Monitor a File for Changes

Problem

You want to monitor the end of a file for new content.

Solution

To monitor the end of a file for new content, use the –Wait parameter of the GetContent cmdlet.

GetContent log.txt Wait

Discussion

The –Wait parameter on the GetContent cmdlet acts much like the traditional Unix tail command with the –follow parameter. If you provide the –Wait parameter, the GetContent cmdlet reads the content of the file but doesn’t exit. When a program appends new content to the end of the file, the GetContent cmdlet returns that content and continues to wait.

Unlike the Unix tail command, the GetContent cmdlet does not support a feature to let you start reading from the end of a file. If you need to monitor the end of an extremely large file, a specialized file moni

toring utility is a valid option.

For more information about the GetContent cmdlet, type GetHelp GetContent. For more information about the –Wait parameter, type GetHelp FileSystem.

A Morocco Dedicated Server gives IT teams dedicated infrastructure for deploying Linux or Windows environments, configuring server services, and managing production workloads according to specific business requirements.

Help Category