Help ME with Shell scripting log files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help ME with Shell scripting log files
# 1  
Old 09-10-2010
Help ME with Shell scripting log files

I currently have a script that was written a while back and it generates it's own log file. I had to recently alter this script so that it would execute another script in parallel 10 times such as the following example;

Code:
   echo "It is currently: ";date
   int=0;
   cap=10;
   while((int < cap))
   do
      echo "INT is--->$int"
      PB_MOD_FACTOR=$int; export PB_MOD_FACTOR
      echo "PB_MOD_FACTOR=====>$PB_MOD_FACTOR"
      test2.sh & > test_$int.log
      ((int += 1))
   done;
   wait;
   echo "It is currently: ";date
   echo "+---------------------------------+"
   echo "<<<END: load_temp_tables() .....>>>"
   echo "+---------------------------------+"

The problem I am having is the main log contains all the displays from the 10 parallel processes. I want these displays to be kept in their individual logs and then once all 10 processes have completed to bring in the 10 log files into the main log. This will then allow the main log to have all the displays in a more readable format.

Any help that can be provided would be greatly appreciated.

---------- Post updated at 09:02 AM ---------- Previous update was at 08:51 AM ----------

well got the first part taken care of -- by moving the command
from this:
Code:
test2.sh & > test_$int.log

to this
Code:
test2.sh > test_$int.log &

Now to pull in all 10 logs into the main log? - any ideas?

Last edited by Scott; 09-10-2010 at 11:16 AM.. Reason: Please use code tags
# 2  
Old 09-10-2010
Here it is:

Code:
i=0
fileBaseName="test_"
fileExt=".log"
while [ ${i} -le 10 ]
do
	date +"%Y%m%d %H:%M:%S" > "${fileBaseName}${i}${fileExt}"
	i=`expr ${i} + 1`
	sleep 1
done

ls -1 "${fileBaseName}"* | sort -t_ -k2 -n | xargs -I {} cat {} >> main_test.log

# 3  
Old 09-10-2010
MySQL Thank you.

That works pretty well thank you.

also I was messing around and found that this will work better for me - hope this thread will help others;

Code:
   int=0;
   fileBaseName="test_"
   fileExt=".log"
 
   while((int < cap))
   do
        less "${fileBaseName}${int}${fileExt}"
        rm -f "${fileBaseName}${int}${fileExt}"
        ((int += 1))
        sleep 1
   done


Last edited by Scott; 09-10-2010 at 12:22 PM.. Reason: Code tags, please...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

UNIX shell scripting programming in files

Create 2 files in unix in 2 different directories, compare them and fetch common words between these 2 files. Print them on the screen and also redirect the output to your home directory in the below format: file 1 | file 2 line no: word 1 | line no: word 1 line no: word 2 | line no: word 2 line... (11 Replies)
Discussion started by: mounica bijjala
11 Replies

2. Shell Programming and Scripting

Shell Scripting on files in directory

Hi, The requirement is below: There are 5 files in a unix directory and i need to pick up latest file from the directory that i can do like this ls -lrt | tail -1 and this file can be processed. now the actual requirement is some times what will happen the second third...on files i.e(ls -lrt... (4 Replies)
Discussion started by: prawinmca
4 Replies

3. UNIX and Linux Applications

Unix Shell Scripting : Comparision of two files

Hi, We need to compare a text file File1.txt and config file File2.txt in a way that it checks if the content of File1.txt exists between the range mentioned in File2.cfg. The range here is the range between col1 and col2 of File2.cfg If the content of File1.txt lies between the range of... (12 Replies)
Discussion started by: CFA
12 Replies

4. Shell Programming and Scripting

Compare two files using shell scripting

Hi, I need to compare two files using shell scripting. Say like: File1 AAAAAAAAAAAAAAAAAAAA BBBBBBBBBBBBBBBBBBBBB CCCCCCCCCCCCCCCCCCCCCCCCC eeeeeeeeeeeeeeeeeeeeeeeee DDDDDDDDDDDDDDDDDDDDDDDDDDDD File2 BBBBBBBBBBBBBBBBBBBBB DDDDDDDDDDDDDDDDDDDDDDDDDDDD AAAAAAAAAAAAAAAAAAAA ... (6 Replies)
Discussion started by: roshParab
6 Replies

5. UNIX for Dummies Questions & Answers

shell scripting with files- how to?

Hi, I'm trying to create a shell script that shows a report of each real user of the system showing for each user the list of files that is in $home and its subdirectories (sorted by hour of modification), clasified by file type, and finally showing the total size and number of files in that... (1 Reply)
Discussion started by: ubu-user
1 Replies

6. Shell Programming and Scripting

how read the flat files from shell scripting

We are using sybase data base and we have the data base name called MasterDB. The data baase MasterDB contains 100's of tables like sample1, sample2, sample3...etc...sample100 To take the count of every table we have to execute the following commands use MasterDB //DB name go //execute... (1 Reply)
Discussion started by: shijoe
1 Replies

7. UNIX for Dummies Questions & Answers

Find and replace in all files using shell scripting

Hi all, I'm looking to find and replace a string in all HTML files within a certain directory, including subdirectories. Normally, I would play with this a little to get it to work, but I can't mess this up, so I'm going to ask here. Basically, I want to find "<title>" in all *.htm* files... (11 Replies)
Discussion started by: slothario
11 Replies

8. Shell Programming and Scripting

How to Rename/Convert Files in Shell Scripting?

Hi All, I want to Rename/Convert all the .doc files in to .pdf format. I am using the following Script. But the final output is not proper. ########################################## cd /u13/prepaid/ftpdata/INfiles/sap/ for name in `ls *.doc` do name1=`echo $name | sed -e... (11 Replies)
Discussion started by: hanu_oracle
11 Replies

9. Shell Programming and Scripting

Comparing two .txt files in shell scripting...

Hi, I have two big .txt files.and i need to compare those two files and redirect it into some other file. If any body wants to resolve this issue then i can send the two text files. Need some quick responce. Thanks, prakash (10 Replies)
Discussion started by: prakash123
10 Replies

10. Shell Programming and Scripting

rename files using shell scripting

Hi all, i want to rename some files in my directory using korn shell scripting. 1) i want to rename files who have no extension so that they will have the format: filename.extension and 2) i want the files who has extension initially, to stay the same (they will not be... (4 Replies)
Discussion started by: gfhgfnhhn
4 Replies
Login or Register to Ask a Question