Online log


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Online log
# 1  
Old 05-03-2005
Online log

Hi,

I have this situation:
There is an online.log to which one app is continuously writing. This app is 24*7.
This log will fill up our File system pretty quickly. Such that
I need to take backups of that file for safekeeping without stopping the App.
These backups I can move to another location.
I tried copy & move, but I had to restart the App at the end.

Do you have any suggestions?
Thanks in advance.

Chaandana
# 2  
Old 05-03-2005
do a google for 'log rotation', there are plenty of examples out there. In this way you keep two or more log files and write to them in round-robin fashion. You can then back up the logs by copying the one(s) not currently being written to.
# 3  
Old 05-03-2005
you could try this one ... it will read yourlog and them empty it right away ... you can them move logcopy somewhere else as you require ...
Code:
(cat yourlog; echo > yourlog) > logcopy

# 4  
Old 05-03-2005
Thanks for your time,

It does not serve my purpose.
Sure, my logfile size goes backto zero.
But the moment my app starts writing to, it restores to its previous size.
This is same as:
cp mylog mylog.bak; cat /dev/null > mylog.

final result is same.

I searched google, there it has some third party tools like cronolog or logrotate, but I still wonder that perhaps this could be done via a some nice tricky shell command/script ?

Chaandana
# 5  
Old 05-03-2005
not really the same but close enough ... anyways, your problem was how to move your log to another directory for safekeeping without turning off the application that keeps on logging to it ...

the code I wrote fixes that problem --- you zero out the log while making a copy of it without stopping the app ... this sounds like the correct solution to your problem as you originally stated it ...

the only way you're going to not make the file size that big is to make the app log much, much less than it currently does ... if you can't do that, run the cat-echo job much more often so you control the file size better ...
# 6  
Old 05-04-2005
Hi All,

I came up with a solution.
It goes like this:

1. mknod $PATH/my.log p

2. ( gzip < $PATH/my.log ) | split -b 50m - /root/my$TIME. &

3. now, I start my app writing to $PATH/my.log

Regards
Login or Register to Ask a Question

Previous Thread | Next Thread

1 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Online log monitoring script

#!/bin/bash tail /oracle/app/admin/ABC/bdump/alert_ABC.log >> tempoutput& Error=`egrep 'error|warn|critical|fail|ORA-1683' tempoutput` echo "$Error" |mailx -s "ABC Error " ABCD@domain.lk cat /dev/null > tempoutput I wrote this script and put in to cronjob every 5 min. so every 5... (4 Replies)
Discussion started by: hishanms
4 Replies
Login or Register to Ask a Question