How to check background tasks status, if fail report


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to check background tasks status, if fail report
# 1  
Old 11-16-2011
MySQL How to check background tasks status, if fail report

Hi,

I have a requirement where I want to submit appx 100 jobs based on the files received. Assume today I received source file for 50 jobs, then I have submit a common script at 50 times.

This common script will take appx 1-2 mins to finish. I can' complete my parent script untill all the 50 submitted jobs completed.

How can I desing for this?

Thanks,
meetvipin
# 2  
Old 11-16-2011
Create a list of process IDs as you create the asynchronous processes. Once you have submitted them all, use the wait command and supply all of the process IDs on the command line. Your script will block until they have all finished.


Code:
#!/usr/bin/env ksh

# probably works the same in bash
 for i in 1 2 3 4
do
   some-command &
   plist="$plist $!"   # add last process id
done


wait $plist     # wait for them all
echo all done


Last edited by agama; 11-16-2011 at 01:09 AM.. Reason: spelling
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Get status of dd running in background job

Hello everyone While working on TUI for scripts, there there came the idea to' add a command' for dd too. That was, after 'wrapping' tar and wget either, to display their growing size and return the exit code with a textual-visual-feedback to the user. Now displaying the filesize of a... (13 Replies)
Discussion started by: sea
13 Replies

2. UNIX for Dummies Questions & Answers

How to make entries background tasks in the table?

Hi am new to unix , when the background task is running how to put entry in the table and also if there is any issue how to stop the running task. can anyone help me... (1 Reply)
Discussion started by: Venkatesh1
1 Replies

3. UNIX for Dummies Questions & Answers

Fail to check disk

Hi there, I can't find any way to check the file system on a partition. The two following command fail with the same result: e2fsck /dev/sdc10 e2fsck -b 8193 /dev/sdc10Output: e2fsck 1.41.3 (12-Oct-2008) e2fsck: Bad magic number in super-block while trying to open /dev/sdc10 The... (0 Replies)
Discussion started by: chebarbudo
0 Replies

4. Shell Programming and Scripting

Background tasks in a loop (bash)

I am trying to use a loop to start tasks 0-3, running 0,1,2 in the background with &. FOLDSET=( 0 1 2 3 ) for FOLDSET in ${FOLDSET} do if ; then BACKGRD="&" else BACKGRD="" fi # start task $FOLDSET task1 -nogui -ni -p $PROJ \ epochs=$EPOS ... (3 Replies)
Discussion started by: LMHmedchem
3 Replies

5. Shell Programming and Scripting

Capturing the exit status of the script running in background

Hi All, I have a scenario where I am executing some child shell scripts in background (using &)through a master parent script. Is there a way I can capture the exit status of each individual child script after the execution is completed. (2 Replies)
Discussion started by: paragkalra
2 Replies

6. Shell Programming and Scripting

How to know the status of process running in background

I have run one shell script in background that contains a endless while loop. I am not able to know the status of that job . Please provide any command to know this. I have already used "ps -aef" , "jobs" to know it , but it didn't work. I am sure the process is running as it is generating a file... (8 Replies)
Discussion started by: sumanta
8 Replies

7. Shell Programming and Scripting

check the status and send an email with status

Hi, We have a text file which has the following data. ISA~00~ ~00~ ~ZZ~VISTN ~ZZ~U1CAD ~051227~183 7~U~00200~000011258~0~P~< GS~FA~EE05J~U1CAD~051227~1831~000011258~X~002002 ST~997~0001 AK1~SH~247 AK2~856~2470001 AK5~A AK2~856~2470002 AK5~A... (3 Replies)
Discussion started by: isingh786
3 Replies

8. Shell Programming and Scripting

retrieving exit status from background processes

Hi, I need to retrieve the exit status of 4 moves running as background processes. The wait command will not work since it can only give me the exit status of the last of the background processes. Here's a sample of what I need !#/bin/ksh mv /dir1/subdir1/*.Z /dir6/subdir6/ & mv... (2 Replies)
Discussion started by: MG537
2 Replies

9. Shell Programming and Scripting

exit status of Invoking two or more scripts in background

I have a sript which is going to trigger other 3 scripts in background simultaneously for eg: Main Script:(main.sh) ----------- sh a.sh & sh b.sh & sh c.sh & How to catch the exit status and store it in a variable for all those three scripts in main script. Is there any other way of... (4 Replies)
Discussion started by: Omkumar
4 Replies
Login or Register to Ask a Question