Consolidating multiple outputs in one file

Dears,
i am stuck here
i have 3 scripts running at one time and all the three scripts finish at different time and each script generate 1 file with different name. so i will have three files.

i dnt know which script finish first
i want to have a script which check if all the there files are created and process is over then join the files and make 1 file.

please help me to archive this

Please provide information on your attempts to resolve.

Until so, we will refrain from sharing any guidance.

The purpose of this Board is the assist users in solving their problems. We are not a coding service. Further, we are not a homework service - and sometimes posts appear to be an attempt to have someone solve a school assignment.

Finally, we urge all members of the Forum to NOT post a solution to this question until effort to resolve is demonstrated.

1 Like

I was not looking for someone to do my homework, i was seeking for some suggestions,
i can try to do it on my own.. but was seeking for some pattern.
you misunderstood my post

OK, then you have 3 programs running that create output.
Would seem that you would want to create one watcher program, perhaps run at regular interval via a cron job.
The watcher program would look to see if the three output files have been created. It would then combine the three files into one.

Some things to consider - is this daily?
Because then you may want to also check to see if you have already created the combined file; thus perhaps checking for the "NOT" existence of the daily combined file.

Another consideration - the order or organization of the combined file. Should the files be combined in the order completed or another order.

1 Like

I would rather suggest to do it via a semaphore and i suggest the thread starter to read up on the concept.

Basically the first script to be started will open the semaphore and do the starting setup and the last one to stop will do the end processing and close the semaphore.

I hope this helps.

bakunin

Another important information is how the scripts are started.
Would it be possible to have a wrapper script to start those 3 scripts in background and use the wait command to wait for all of them to finish, then combine the output?

1 Like

i have worked it out by making a script and scheduling in cron
it keep on running and wait for the three file, once three files exist, it concatenate all the three in 1 and then send email

please close this thread