Need to create 2 log files


 
Thread Tools Search this Thread
# 1  
Question Need to create 2 log files

Hello, and thanks upfront for looking!

I've been searching the threads for a way to do this, and have come up empty. Then again I don't seem to use the right search criteria...

We have a driver script which logs output to files which are used to be viewed via an online scheduling tool:
$EXECDIR/$process >> $PROC_LOG_FILE 2>&1

Within the KSH script being called by the driver, we write to a different log file, which is used for ops support. The way it's set today, all we do is echo certain things to the local log file via "echo | tee -a $LOCAL_LOG_FILE" command. This is problematic because we don't capture all the STDOUT and STDERR in this log. I would like both log files to contain the same information without touching the command from the driver script.

Can someone help out?

Appreciate your help.
Thanks!
Pete
# 2  
I don't understand what you're using 'echo' for at all.

Why not just run the same command the same way? command >> logfile 2>&1
# 3  
Thanks for your reply Corona.

Basically we echo what we're going to do and write that to the local log. Then we run command, and it's STDOUT and STDERR is captured in the log file used for display on the web tool, but the local log file doesn't catpure this. I also would rather not do "cmd >> logfile 2>&1" for each of the commands in the script, so I was hoping there was an easier way to accomplish this....
# 4  
Run the script itself with > logfile 2>&1 then?

Or at the top of the script:

Code:
# Redirect stdout into logfile
exec 1>logfile
# Redirect stderr into stdout
exec 2>&1

# 5  
Within the ksh script possibly remove the existing "tee" commands and wrap the entire contents in a sub-shell:
Code:
#!/bin/ksh
# Preamble and set logfile variable
(

#Lines which output to stdout or stderr


) 2>&1 | tee -a $LOCAL_LOG_FILE

# 6  
Thanks Methyl and Corona,

I believe the subshell method stands a chance at working the way I need it to. The issue with Corona's approach is that the local log file would contain all the output and the other would contain nothing. I'll try it out....
 

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to create or convert to pdf files from csv files using shell script?

Hi, Can anyone help me how to convert a .csv file to a .pdf file using shell script Thanks (2 Replies)
Discussion started by: ssk250
2 Replies

2. Shell Programming and Scripting

Create multiple zip files each containing 50 xml files.

Hi, Is there a direct command or need to write a shell script for following requirement? Everyday a folder is populated with approx 25k to 30k xml files. I need to create multiple zip files in the same folder each containing 50 xml files. The last zip file may or may not contain 50 xml files.... (6 Replies)
Discussion started by: Rakesh Thobula
6 Replies

3. Shell Programming and Scripting

How to create zip/gz/tar files for if the files are older than particular days in UNIX or Linux?

I need a script file for backup (zip or tar or gz) of old log files in our unix server (causing the space problem). Could you please help me to create the zip or gz files for each log files in current directory and sub-directories also? I found one command which is to create gz file for the... (4 Replies)
Discussion started by: Mallikgm
4 Replies

4. Shell Programming and Scripting

Need to count files & create log of that.

Hi Friends, I need some help. First look at my files hierchachy /<level-1>/<level-2>/<level-3>/*.tif eg. : /2010-07-01/AFFIDAVIT-OF-SERVICE---FOR-SC/001/Babylon2_20100701012049_1278004849.49892_000.tif... (2 Replies)
Discussion started by: paragnehete
2 Replies

5. Homework & Coursework Questions

shell script that can create, monitor the log files and report the issues for matching pattern

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Write an automated shell program(s) that can create, monitor the log files and report the issues for matching... (0 Replies)
Discussion started by: itian2010
0 Replies

6. Shell Programming and Scripting

Write an automated shell program(s) that can create, monitor the log files and report the issues for

Hi , Please help me getting this done. Write an automated shell program(s) that can create, monitor the log files and report the issues for matching pattern. (i) Conditions for creating log files. Log file is created with date (example 2010_03_27.log). If the log file size is 10 Mb for... (1 Reply)
Discussion started by: itian2010
1 Replies

7. Shell Programming and Scripting

Help to create a script to parse log files

Hello everybody, I need some help here to create a script to parse a log file. Here is a sample of the log file : 0x42258940 (Debug) Cache SUMMARY attrs now/668 min/668 max/668. 0x42258940 (Debug) RSVD SUMMARY reserved space max requested/128 MB accounted now/0 MB 0x42258940 (Debug)... (12 Replies)
Discussion started by: Samb95
12 Replies

8. Shell Programming and Scripting

Read multiple log files and create output file and put the result

OS : Linux 2.6.9-67 - Red Hat Enterprise Linux ES release 4 Looking for a script that reads the following log files that gets generated everynight between 2 - 5am Master_App_20090717.log Master_App1_20090717.log Master_App2_20090717.log Master_App3_20090717.log... (2 Replies)
Discussion started by: aavam
2 Replies

9. UNIX for Dummies Questions & Answers

Create individual tgz files from a set of files

Hello I have a ton of files in a directory of the format app.log.2008-04-04 I'd like to run a command that would archive each of these files as app.log.2008-04-04.tgz I tried a few combinations of find with xargs etc but no luck. Thanks Amit (4 Replies)
Discussion started by: amitg
4 Replies

Featured Tech Videos