Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

2 questions re: creating script to exec multiple background processes

Status
Not open for further replies.

tdfreeman

MIS
Mar 28, 2002
85
US
I am trying to lessen the time it takes to export a database. In doing so, I am breaking the export down into 10 exports that export different tables. I want to create a script that executes each export and then puts it in the background.

I have succeeded in this much. My two issues with the script are as follows:

Since each export is in the background, how can I get the log file for each export emailed to users after the export is finished?

Also, when all background processes are finished my script just sits there like it is waiting on something. I have to press enter to get back to a prompt. I want the session to stay in the script until all exports are complete and then exit the script. That will also help in determining when all exports in the script are finished. How can I do this?

Thank you for your help.

Tammy
 
for starters: thread822-362187
vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
Submit your background processes with [tt]at[/tt] instead of [tt]&[/tt]ing them off.

echo &quot;exp blah blah blah&quot; | at now
 
Thanks for the help. I can't use at and I don't really understand the $! answer. I am going to use cron.
 
Is it a security thing that prevents you from using at?

If it's a matter of the &quot;master&quot; script knowing when each sub-script completes, I would implement semaphore files.

main script: (mix of proper syntax + pseudo)

rm sem[123] 2>/dev/null #(clean up any existing ones that don't belong)

touch sem1 sem2 sem3

echo &quot;subscript1; rm sem1&quot; | at now
echo &quot;subscript2; rm sem2&quot; | at now
echo &quot;subscript3; rm sem3&quot; | at now

Q=1
while test $Q is greater than 0
do
sleep for a minute or however often you want to check
A=test for existence of sem1
B=test for existence of sem2
C=test for existence of sem3
Q=A+B+C
if A not 0: echo &quot;subscript 1 is still running&quot;
if B not 0: echo &quot;subscript 2 is still running&quot;
if C not 0: echo &quot;subscript 3 is still running&quot;
done
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top