Snafui.com - Perl Tail Output Separator

Here's a handy script by Chris Austin to separate some tail -f output. Hard to explain but you know how you will "tail -f" a log file, like httpd logs when debugging a perl or cgi script and to make it easier on yourself you may hit enter a few 4 or 5 times to make some blank space before the error logs get written to again? Well this script acts as an output filter or wrapper to tail to make a clearly distinguishing line of ==== equal signs to separate output. It'll draw a line after 2 seconds of tail idle time.

Syntax
Assuming you called the script 'sep'
tail -f /var/log/httpd/error_log | sep

Install
To install just paste the code below into a file that is in your PATH and make it executable with chmod +x. Depending on your shell you may need to rehash or re-login.

Code

   #!/usr/bin/perl
   $SIG{ALRM}=sub{printf"\n%s\n",'='x120};
   print&&alarm(2)while<>

(Chris is known for making scripts with no white space)

An example of the output may make it easier to see what this does:

[Mon Nov 24 08:04:28 2003] [notice] SIGUSR1 received.  Doing graceful restart
[Mon Nov 24 08:04:29 2003] [notice] Apache/1.3.28 (Unix) configured -- resuming normal operations
[Mon Nov 24 08:04:29 2003] [notice] Accept mutex: flock (Default: flock)

========================================================================================================================
[Tue Nov 25 09:16:37 2003] [error] [client 192.168.1.51] File does not exist: /usr/local/www/data/favicon.ico

========================================================================================================================