bergman on 22 Sep 2009 19:40:21 -0700 |
In the message dated: Tue, 22 Sep 2009 22:21:30 EDT, The pithy ruminations from Walt Mankowski on <Re: [PLUG] correct way to do this in bash> were: => [SNIP!] => => Another solution no one's suggested yet is to change the log files Yet another option, since we're getting further from the initial question, is to replace the logfile with a FIFO*. This leaves the data generating program unchanged, and alows you to use any program you want to receive the log data and slice & dice & rotate it as needed. For example: mknod /var/log/fifo huge_simulation_program > /var/log/fifo processlogs < /var/log/fifo & [OB-BASH] Where the script "processlogs" is something like this completely untested, off-the-top-of-my-head code: #################################### #! /bin/bash count=0 while [ 0 ] do while [read input] do now=` date "+%H%M%S"` if [ $now = 080000 ] ; then # it's 8AM...of course, this test is bound to fail # if the loop takes more than 1second count=$((count + 1)) compressneeded=YES fi echo $input >> /var/log/logfile.$count if [ $compressneeded = YES ] ; then bzip2 /var/log/logfile.$((count - 1)) & compressneeded = NO fi done done ######################################## [/OB-BASH] * http://www.linuxjournal.com/article/2156 http://en.wikipedia.org/wiki/Named_pipe Mark => Walt => ___________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug
|
|