Operating System - HP-UX
1753521 Members
4867 Online
108795 Solutions
New Discussion юеВ

Re: Redirect Logs into Other file

 
SOLVED
Go to solution
Khalid Shakoor
Regular Advisor

Redirect Logs into Other file

Hi Guruz,

I want to create a script, which Capture the month, year from my alert database log file and redirect the output in another txt file of other location as backup logs.

If someone have this kind of Script please share with me.

Thanks in Advance.
Khalid
8 REPLIES 8
Horia Chirculescu
Honored Contributor

Re: Redirect Logs into Other file

Hello,

If you are talking about some unix script, you should use the shell's redirect functions (the shell that you use in the script).

Best regards,
Horia.


Best regards from Romania,
Horia.
James R. Ferguson
Acclaimed Contributor

Re: Redirect Logs into Other file

Hi:

> I want to create a script, which Capture the month, year from my alert database log file and redirect the output in another txt file of other location as backup logs.

Perhaps if you showed us your input and your desired output we could help. I assume that you know basic shell concepts.

Regards!

...JRF...
Khalid Shakoor
Regular Advisor

Re: Redirect Logs into Other file

Hi

Thanks for your Response

Now i am attaching a log file,Its have two month log June and July,
I want to split June and July year 2009 and redirect into another file.

I try it but its showing me only date like

Sun Jun 21 18:38:47 2009
Sun Jun 21 18:45:08 2009
Sun Jun 21 18:51:30 2009
Sun Jun 21 18:57:50 2009

Please help me to split these logs using month and year filter.

Thanks
Khalid
Khalid Shakoor
Regular Advisor

Re: Redirect Logs into Other file

I don't know why its not submit my attachemt.

Please find below the sample of Logs file

============================================
Tue Jun 30 23:51:39 2009
Copy of datafile 28 complete to datafile copy /u02/rbkp/u01/oradata/iiris_web.dbf
checkpoint is 88164327751
Tue Jun 30 23:51:47 2009
alter database create standby controlfile as '/u02/rbkp/u01/oradata/control01.ctl.stdby' reuse
Clearing standby activation ID 3180359789 (0xbd90706d)
The primary database controlfile was created using the
'MAXLOGFILES 255' clause.
There is space for up to 245 standby redo logfiles
Use the following SQL commands on the standby database to create
standby redo logfiles that match the primary database:
ALTER DATABASE ADD STANDBY LOGFILE 'srl1.f' SIZE 104857600;
ALTER DATABASE ADD STANDBY LOGFILE 'srl2.f' SIZE 104857600;
ALTER DATABASE ADD STANDBY LOGFILE 'srl3.f' SIZE 104857600;
ALTER DATABASE ADD STANDBY LOGFILE 'srl4.f' SIZE 104857600;
ALTER DATABASE ADD STANDBY LOGFILE 'srl5.f' SIZE 104857600;
ALTER DATABASE ADD STANDBY LOGFILE 'srl6.f' SIZE 104857600;
ALTER DATABASE ADD STANDBY LOGFILE 'srl7.f' SIZE 104857600;
ALTER DATABASE ADD STANDBY LOGFILE 'srl8.f' SIZE 104857600;
ALTER DATABASE ADD STANDBY LOGFILE 'srl9.f' SIZE 104857600;
ALTER DATABASE ADD STANDBY LOGFILE 'srl10.f' SIZE 104857600;
ALTER DATABASE ADD STANDBY LOGFILE 'srl11.f' SIZE 104857600;
Completed: alter database create standby controlfile as '/u02
Tue Jun 30 23:53:56 2009
Errors in file /ora/app/oracle/admin/kic/bdump/kic1_arc0_1042007.trc:
ORA-12541: TNS:no listener
Tue Jun 30 23:59:02 2009
Errors in file /ora/app/oracle/admin/kic/bdump/kic1_arc0_1042007.trc:
ORA-12541: TNS:no listener
Wed Jul 1 00:00:03 2009
Errors in file /ora/app/oracle/admin/kic/bdump/kic1_arc0_1042007.trc:
ORA-12541: TNS:no listener
Wed Jul 1 00:05:09 2009
Errors in file /ora/app/oracle/admin/kic/bdump/kic1_arc0_1042007.trc:
ORA-12541: TNS:no listener
Wed Jul 1 00:10:17 2009
Errors in file /ora/app/oracle/admin/kic/bdump/kic1_arc0_1042007.trc:
ORA-12541: TNS:no listener
Wed Jul 1 00:15:23 2009
Errors in file /ora/app/oracle/admin/kic/bdump/kic1_arc0_1042007.trc:
ORA-12541: TNS:no listener
Wed Jul 1 00:20:30 2009
Errors in file /ora/app/oracle/admin/kic/bdump/kic1_arc0_1042007.trc:
ORA-12541: TNS:no listener
Wed Jul 1 00:25:37 2009
Errors in file /ora/app/oracle/admin/kic/bdump/kic1_arc0_1042007.trc:
ORA-12541: TNS:no listener
Wed Jul 1 00:30:44 2009
Errors in file /ora/app/oracle/admin/kic/bdump/kic1_arc0_1042007.trc:
ORA-12541: TNS:no listener
Wed Jul 1 00:35:51 2009
Errors in file /ora/app/oracle/admin/kic/bdump/kic1_arc0_1042007.trc:
ORA-12541: TNS:no listener
============================================

Thanks
Khalid
Dennis Handly
Acclaimed Contributor
Solution

Re: Redirect Logs into Other file

Depending on your timestamp format and locale, you could use something like:
awk '
# assume timestamp is first
BEGIN {
getline
logname = $5 "_" $2 ".log"
print $0 > logname
}
# assume this matches timestamp
NF == 5 && length($1) == 3 && length($2) == 3 && length($4) == 8 && length($5) == 4 {
logname2 = $5 "_" $2 ".log"
if (logname2 != logname) {
close(logname)
logname = logname2
}
print $0 > logname
next
}
{
print $0 > logname
}' input-log

This will create files with YYYY_MMM.log.
Khalid Shakoor
Regular Advisor

Re: Redirect Logs into Other file

Thanks Dennis,

Its working for me.

Regards
Khalid
Horia Chirculescu
Honored Contributor

Re: Redirect Logs into Other file

Hello,

You can check also a more complex solution:

http://logdistiller.sourceforge.net/

It has log parsing facilities.

Best regards,
Horia.

Best regards from Romania,
Horia.
Khalid Shakoor
Regular Advisor

Re: Redirect Logs into Other file

Dear All,
Thanks a lot.

Khalid Shakoor