Sponsored Content
Top Forums Shell Programming and Scripting If I ran perl script again,old logs should move with today date and new logs should generate. Post 303014562 by MadeInGermany on Wednesday 14th of March 2018 03:27:28 PM
Old 03-14-2018
I think you must detect if it's the first write to each logfile.
This is done with a hash (associative arrary).
Code:
...
while(<>) {
  if (/^#(\w+)#(.+)$/) {
    if ($last_name ne $1) {
      close $writeout if $writeout;
      if (!defined $fn{$1}) {
# not yet in hash => rename if present
        if (-f "$1.log") { rename "$1.log","$1.log.old"; }
# put in hash
        $fn{$1}="";
      }
      open($writeout, '>>', "$1.log");
    }
...

This renames to .old. Putting a date is left as an exercise.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove out date logs

hi all, i would like to write the shell script to remove the out-dated log my log file name will be like this: access_20050101.log access_20050102.log . . . access_20071007.log access_20071008.log access_20071009.log i has try to write the command as following, it will be remove the... (2 Replies)
Discussion started by: eric_wong_ch
2 Replies

2. Shell Programming and Scripting

Perl script to rotate logs

I have a shell script that will gzip/tar/archive application logs that are over 20 days old which works just fine, but I would like to convert to a Perl script. Problem is, I'm a beginner with Perl and all attempts so far have failed. Basicaly I have a log dir /app/logs that contains several... (18 Replies)
Discussion started by: theninja
18 Replies

3. Solaris

Remove logs by date

Hi I Need To Remove Logs Older Than April 1 St(4/1/2007) By Date I Have A Script To Remove 3 Months Old Like Using 90 Days Thanks (3 Replies)
Discussion started by: cvdev
3 Replies

4. Shell Programming and Scripting

script to move logs

Does anyone have a good script to move log files from a cron? There are a lot of logs, about 100 or more and they are constantly being written too. (7 Replies)
Discussion started by: photon
7 Replies

5. Shell Programming and Scripting

Grep yesterday logs from weblogic logs

Hi, I am trying to write a script which would go search and get the info from the logs based on yesterday timestamp and write yesterday logs in new file. The log file format is as follows: """"""""""""""""""""""""""... (3 Replies)
Discussion started by: harish.parker
3 Replies

6. Shell Programming and Scripting

shell script to auto process ten random files and generate logs

Hello member's I'm learning to script in the ksh environment on a Solaris Box. I have 10 files in a directory that I need to pass, as input to a batch job one by one. lets say, the files are named as follows: abcd.txt ; efgh.bat ; wxyz.temp etc. (random filenames with varied extensions ).... (1 Reply)
Discussion started by: novice82
1 Replies

7. Shell Programming and Scripting

Lots of logs to move....don't remove if open

I have a ksh script that currently moves a day's worth of log files (about 15,000) files to a different directory. The issue is that about 100 of these files are still open for write when this happens. I need an efficient way to ensure that these files aren't open without doing an lsof on each... (7 Replies)
Discussion started by: nestafaria
7 Replies

8. Shell Programming and Scripting

Script to Search Logs Several Directories Pulling out Only Current Date

Hi All.. I'm seeking assistance with editing a script to search log files in several directories. I'm close to what I'm seeking, but need additional guidance. The log files are always listed by current date; however, inside the log file includes dates that go back to 2011. What I'm... (6 Replies)
Discussion started by: lenaf7
6 Replies

9. Shell Programming and Scripting

Perl script to parse multiple windows event logs.

Hi all, I am developing a log parsing agent in perl to send windows Event logs to Zenoss Monitoring tool. Using Win32::EventLog i can able to get the Event messages but only one Eventype eg Application or System could able to parse at a time. Can you please help to how to open mutiple eventlogs... (3 Replies)
Discussion started by: kar_333
3 Replies

10. Shell Programming and Scripting

Perl script to extract last 24 hrs logs from cronlog

Hi Friends, Can anybody help me to create a perl script to generate log file for last 24 hrs from cron log file ?? Thank You (2 Replies)
Discussion started by: syamji.vm
2 Replies
POE::Component::IRC::Plugin::Logger(3pm)		User Contributed Perl Documentation		  POE::Component::IRC::Plugin::Logger(3pm)

NAME
POE::Component::IRC::Plugin::Logger - A PoCo-IRC plugin which logs public, private, and DCC chat messages to disk SYNOPSIS
use POE::Component::IRC::Plugin::Logger; $irc->plugin_add('Logger', POE::Component::IRC::Plugin::Logger->new( Path => '/home/me/irclogs', DCC => 0, Private => 0, Public => 1, )); DESCRIPTION
POE::Component::IRC::Plugin::Logger is a POE::Component::IRC plugin. It logs messages and CTCP ACTIONs to either #some_channel.log or some_nickname.log in the supplied path. In the case of DCC chats, a '=' is prepended to the nickname (like in irssi). The plugin tries to detect UTF-8 encoding of every message or else falls back to CP1252, like irssi (and, supposedly, mIRC) does by default. Resulting log files will be UTF-8 encoded. The default log format is similar to xchat's, except that it's sane and parsable. This plugin requires the IRC component to be POE::Component::IRC::State or a subclass thereof. It also requires a POE::Component::IRC::Plugin::BotTraffic to be in the plugin pipeline. It will be added automatically if it is not present. METHODS
"new" Arguments: 'Path', the place where you want the logs saved. 'Private', whether or not to log private messages. Defaults to 1. 'Public', whether or not to log public messages. Defaults to 1. 'DCC', whether or not to log DCC chats. Defaults to 1. 'Notices', whether or not to log NOTICEs. Defaults to 0. 'Sort_by_date', whether or not to split log files by date, i.e. #channel/YYYY-MM-DD.log instead of #channel.log. If enabled, the date will be omitted from the timestamp. Defaults to 0. 'Strip_color', whether or not to strip all color codes from messages. Defaults to 0. 'Strip_formatting', whether or not to strip all formatting codes from messages. Defaults to 0. 'Restricted', set this to 1 if you want all directories/files to be created without read permissions for other users (i.e. 700 for dirs and 600 for files). Defaults to 1. 'Format', a hash reference representing the log format, if you want to define your own. See the source for details. 'Log_sub', a subroutine reference which can be used to override the file logging. Use this if you want to store logs in a database instead, for example. It will be called with 3 arguments: the context (a channel name or nickname), a type (e.g. 'privmsg' or '+b', and any arguments to that type. You can make use "default_format" to create logs that match the default log format. Note: You must take care of handling date/time and stripping colors/formatting codes yourself. Returns a plugin object suitable for feeding to POE::Component::IRC's "plugin_add" method. "default_format" Returns a hash reference of type/subroutine pairs, for formatting logs according to the default log format. AUTHOR
Hinrik Oern Sigur`sson, hinrik.sig@gmail.com perl v5.14.2 2011-12-07 POE::Component::IRC::Plugin::Logger(3pm)
All times are GMT -4. The time now is 04:54 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy