Stream all log files into one file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Stream all log files into one file
# 1  
Old 10-11-2010
Stream all log files into one file

Here is what I have.
1 main program and it calls several child programs. Each child has its own log file. I want all child logs also to be appended to the main.log so that I have a single log file. I also need individual child logfiles in tact for debug purposes. Need to be able to tail one log file instead of tens of child logs as they run..
I am free to modify either child or main program to accomplish this. How do it do this?

main.sh
log=main.log
echo "Entering main .log" >> $log
child1.sh

child1.sh
log=child.log
echo "this is child1" >> $log
# 2  
Old 10-11-2010
give main.log a specific name like mainLog=main.log
and at end of child1.sh
cat $log >> $mainLog
this should solve the purpose
# 3  
Old 10-11-2010
Unfortunately I cannot as main runs so many number of times in a day. I have every log file named as main_$now.log and child as child_$now.log where now is date + %ymdhms% format.
# 4  
Old 10-11-2010
It always helps to know what Shell you are running.

I think that the unix "tee" command can be used to achieve the desired effect providing that every child log is written to by a unix Shell redirect (i.e. not directly by a program). The unix "tee" command splits the input from a pipe into two directions (like a tee-piece in plumbing).

Code:
echo "Log entry" | tee combined.log >> child.log

This approach is not suitable for high-intensity logs or mission-critical logs because Shell is not 100% reliable with concurrent writes to the same file.
The technique is very good for creating a central server log of say service ups and downs.
# 5  
Old 10-12-2010
I tried tee but its not able to write to the combined.log as its already opened by the main.sh.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Windows & DOS: Issues & Discussions

Play STRG - E-Viewer Recorded Stream file

I have got a .strg file, which I cannot open. I tried NMS Player from Novus, but It can't handle STRG files. How can I play these recordings? (1 Reply)
Discussion started by: kovacsdev
1 Replies

2. Shell Programming and Scripting

Wget for downloading a public file (stream) as mp4

I need a hint for using wget for getting a free content from a TV station that is streaming its material for a while until it appears on any video platform, that means no use of illegal methods, because it is on air, recently published and available. But reading the manual for wget I tried the... (5 Replies)
Discussion started by: 1in10
5 Replies

3. Shell Programming and Scripting

Creating a file from input stream

Hi, Need some help with creating a file from input steam. Meaning from following command myfunc should be able to store the input stream to a file. echo a b c | myfunc The file thus created should have - a b c Here's what I've tried in myfunc() but didn't help - myfunc() { cat... (3 Replies)
Discussion started by: nexional
3 Replies

4. AIX

When AIX audit start, How to set the /audit/stream.out file size ?

Dear All When I start the AIX(6100-06)audit subsystem. the log will save in /audit/stream.out (or /audit/trail), but in default when /audit/stream.out to grow up to 150MB. It will replace the original /audit/stream.out (or /audit/trail). Then the /audit/stream.out become empty and... (2 Replies)
Discussion started by: nnnnnnine
2 Replies

5. UNIX for Dummies Questions & Answers

What is an (application/octet-stream) file?

I'm trying to learn as much about GRUB as I can and it's stages are stored in these types of files. Any info or search terms is appreciated!:wall: (5 Replies)
Discussion started by: theKbStockpiler
5 Replies

6. Shell Programming and Scripting

Removing all lines prior to the last pattern in a file/stream

Hi all, I didn't find anything that specifically answers this after searching for a bit, so please forgive me if this has been covered before. I'm looking to delete all lines prior to the last occurrence of a string in a file or stream from within a shell script (bash.) A bit of... (4 Replies)
Discussion started by: LivinFree
4 Replies

7. Shell Programming and Scripting

[Video stream] network stream recording with mplayer

Hi I used this command: mplayer http://host/axis-cgi/mjpg/video.cgi -user root -passwd root \ -cache 1024 -fps 25.0 -nosound -vc ffh264 \ -demuxer 3 -dumpstream -dumpfile output.avi It's ok but... Video Playing is very fast! Why? Is it a synch problem? What parameter I have to use for... (1 Reply)
Discussion started by: takeo.kikuta
1 Replies

8. Shell Programming and Scripting

Using Awk for stream log

Hi Master, I've log in here then try parsing log become : 3GPP-IMSI,Calling-Station-Id 528111500111614,6738790448 528111500068173,6738769831 ..... it is possible to use awk? cause i 've try awk ' /\Accounting\ /{f=1} f && /\3GPP-IMSI \:\ String Value\ /{imsi=$4} f &&... (1 Reply)
Discussion started by: bowbowz
1 Replies

9. Programming

open file stream problem

I have faced a problem that I use 2 file streams in a function and try to fopen() both files. Then I can't get the file descriptor. But if I just use 1 file stream and 1 fopen(), then i can get the file descriptor. Does anybody know why this happens? Thanks in advance. ... (2 Replies)
Discussion started by: ivancheung
2 Replies

10. Programming

File I/O Stream

Hi All, I am trying to read data from two files and then compare them and only print the records on the screen that have a same ID.i.e TAGNO =CUSTOMERNO For Eg My Input Files are (a) Transaction (b) Customer detail The data in file a is like: TagNo Date Time Station... (0 Replies)
Discussion started by: rooh
0 Replies
Login or Register to Ask a Question