Log monitoring with swatch

When you think of Swatch, you probably think of the Swiss watch company. However, for the UNIX community swatch is a venerable active log file-monitoring tool that is written as a Perl script. A variant of the watch command, swatch is both simple

    Requires Free Membership to View

and feature-filled. The tool extends tail –f and grep to view records in various log files. To the capabilities of these two commands, swatch adds pattern matching and more response options.

After downloading swatch, unpacking it, and building it, the installation is straightforward. The script runs and determines which log files and capabilities are on your system, then it downloads any modules it needs to support monitoring those files. There is a manual installation, but most people accept the default. If the script doesn't complete itself, you should repeat the installation. After installation, you will find the executable file in the /usr/local/bin directory.

You'll need to create a configuration file for swatch, usually a file called .swatchrc, that is placed in a user's home directory. The distribution comes with sample uses of the command. For example, the watchfor command will find a match for a string; echo and bell show the matches on your screen and ring your bell, and mail will send a record of the match to the UID specified when swatch runs.

Barrie Sosinsky is president of consulting company Sosinsky and Associates (Medfield MA). He has written extensively on a variety of computer topics. His company specializes in custom software (database and Web related), training and technical documentation.

This was first published in December 2003

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.