How to make parallel execution on folder ?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to make parallel execution on folder ?
# 1  
Old 10-28-2014
How to make parallel execution on folder ?

I have few very huge files ~ 2 Billion rows of 130 column(CDR data) in a folder, I have written shell script need to read on each file in a folder and will create a new files based on some logic.

But problem is it's taking time to create a new file due to the size , So i dont want to corrupt the data while one process reading the file when i have concurrent run. So required some mechanism to intimate the process that the files is already in process i.e take the next file to process.

I was thinking on flock but not sure will it help me or not !

Can some one suggest me an idea to implement this process?

Thanks
# 2  
Old 10-28-2014
I'm not sure I understand your setup, but would creating the result files in a different directory help?
# 3  
Old 10-28-2014
Hi Rudic,

The shell script will read the files and create the new files with required column , Example if i have file1.csv contain 120 column my requirement is to create new file only with 30 column.

For the above process i am creating temp files to re-structure the files.

In this case if some one tries to run the shell for the same file it will corrupt the data.

So need to implement file level lock or flag mechanism.
# 4  
Old 10-28-2014
Quote:
Originally Posted by rspwilliam
. . .
In this case if some one tries to run the shell for the same file it will corrupt the data.
. . .
Why and how?
# 5  
Old 10-28-2014
Hi Rudic

Please find the attachment , Basically the script is to re-arrange the column in a file to required column.

Example: File1.csv contain column 1,2,3 but the file we required in 2,1,3 order

The attached script will read the order from the control /metadata table and re-arrange the columns.

In the above case if my folder contain 10 files, i need to make sure parallel access should not cause data corrupt or repeating of work.
# 6  
Old 10-28-2014
You need to make up your mind what you want to achieve and what restrictions you have to obey.
Can you suppress parallel execution of your script by using e.g. a file in the /var/run directory (which would be easiest)?
Can you (temporarily) move the files acted upon to a different directory?
Can you log the files acted upon and have your script respect this info?
# 7  
Old 10-28-2014
Hi.

One technique for parallelizing processing on large files is to use GNU parallel. If you are interested in re-arranging the order of fields in a file, say with cut or awk, then parallel can create a sequence of processes to do this in chunks.

Here's an example from the man page:
Code:
EXAMPLE: Processing a big file using more cores
       To process a big file or some output you can use --pipe to split up the
       data into blocks and pipe the blocks into the processing program.

       If the program is gzip -9 you can do:

       cat bigfile | parallel --pipe --recend '' -k gzip -9 >bigfile.gz

       This will split bigfile into blocks of 1 MB and pass that to gzip -9 in
       parallel. One gzip will be run per CPU core. The output of gzip -9 will
       be kept in order and saved to bigfile.gz

       gzip works fine if the output is appended, but some processing does not
       work like that - for example sorting. For this GNU parallel can put the
       output of each command into a file. This will sort a big file in
       parallel:

       cat bigfile | parallel --pipe --files sort | parallel -Xj1 sort -m {}
       ';' rm {} >bigfile.sort

       Here bigfile is split into blocks of around 1MB, each block ending in
       '\n' (which is the default for --recend). Each block is passed to sort
       and the output from sort is saved into files. These files are passed to
       the second parallel that runs sort -m on the files before it removes
       the files. The output is saved to bigfile.sort.

Note that it covers two cases, the second being where the process cannot do simple appending.

Best wishes ... cheers, drl
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Parallel execution on multiple servers in UNIX

I have a requirement (in a shell script) to connect to several servers at once and execute a series of commands. I am aware that ssh can be used for sequential execution. But since most of the commands that I need to execute take a long time, I have to go for the parallel option. Is there... (2 Replies)
Discussion started by: sneha1887
2 Replies

2. UNIX for Advanced & Expert Users

Parallel Execution of Command

Hi All, We have a table that has to store around 80-100 million records. The table is partitioned by a column called Market Code. There are 30 partitions each corresponding to one MRKT_CD. The source of this table is a join between 3-4 other tables. We are loading this table through SQLPLUS... (2 Replies)
Discussion started by: jerome_rajan
2 Replies

3. Programming

Parallel Execution of Programs

Since there've been a few requests for a method to execute commands on multiple CPUs (logical or physical), with various levels of shell-, make-, or Perl-based solutions, ranging from well-done to well-meant, and mostly specific to a certain problem, I've started to write a C-based solution... (4 Replies)
Discussion started by: pludi
4 Replies

4. Shell Programming and Scripting

Parallel execution of script not syncronize

I am haveing 2 scripts, 1st script calls 2ed script for each parameter.(parameters are kept in a different txt file) 1st script for x in `cat Export_Tables_List.txt` do sh Exp_Table.sh $x & done echo -e "1) following tables are successfully exported : \n" > temp cat... (1 Reply)
Discussion started by: sbmk_design
1 Replies

5. Shell Programming and Scripting

Conditional execution and parallel jobs

how can i process jobs parallel with conditions below. Script1.ksh Script2.ksh Script3.ksh Script4.ksh Script5.ksh Script6.ksh Script7.ksh Script8.ksh Script9.ksh Script10.ksh After successful completion of Script1.ksh I need to run Script7.ksh. After successful... (4 Replies)
Discussion started by: ford2020
4 Replies

6. Shell Programming and Scripting

Parallel Job Execution

Hi All, At present I am using a UNIX Script which is running a set of JOBS. These JOBS are to be repeated for 20 times, means the same set of JOBS are repeated by just passing different arguments (From 1 to 20). Is there any way by which I can execute them parallel? At present its all... (4 Replies)
Discussion started by: Prashantckc
4 Replies

7. High Performance Computing

Parallel Execution on Multiple System

Hi All, I am working on a project where I need to execute set of arguments (around 500) on a Simulator. If I execute this on one linux (RedHat 8.0) machine it will approximately takes 2~3 days. Since I am having more linux machines am thinking of executing these on different machines in... (7 Replies)
Discussion started by: 123an
7 Replies

8. Shell Programming and Scripting

Job Execution in Parallel and Maintain Dependency

All, We need to run multiple jobs in parallel with the dependencies intact. I was trying to use the same with &, but in vain. Is there is any other way to resolve this issue. I need to run Set1 A.sh B.sh C.sh Set2 D.sh E.sh Set3 F.sh (10 Replies)
Discussion started by: anand_msm
10 Replies

9. AIX

Make : parallel execution

Hi, Is there any way to run parallel jobs using make command? I am using non-GNU make utility on AIX 4.3. I want to run 2 jobs symultaneously using make utility. Thanks. Suman (0 Replies)
Discussion started by: suman_jakkula
0 Replies

10. Shell Programming and Scripting

Parallel Execution

Hello, I wish to run parallel process forked from one script. Currently I doing is submit them in background. For example: --------------------------------------------------------------- #!/usr/bin/ksh process1 & process2 & process3 & ..... ..... #here I check for completion of... (4 Replies)
Discussion started by: RishiPahuja
4 Replies
Login or Register to Ask a Question