Sponsored Content
Top Forums Shell Programming and Scripting Background tasks in a loop (bash) Post 302507814 by LMHmedchem on Thursday 24th of March 2011 11:29:40 PM
Old 03-25-2011
Quote:
Originally Posted by Corona688
Code:
task1 -nogui -ni -p $PROJ \
      epochs=$EPOS  batches=$BATCH  n_threads=$THRD \
      arch=$ARCH  data_set=$DSET  fldTag=f$FOLDSET  $BACKGRD &

$BACKGRD has the value of "&" for the first three time through the loop, but apparently that doesn't work.

I can probably do this like ,
Code:
FOLDSET=( 0 1 2 3 )

for FOLDSET in ${FOLDSET[@]}
do
   if [ $FOLDSET -lt 3 ]; then
      # start the first three in the background
      task1 -nogui -ni -p $PROJ \
         epochs=$EPOS  batches=$BATCH  n_threads=$THRD \
         arch=$ARCH  data_set=$DSET  fldTag=f$FOLDSET &
   else
      # wait on the last one
      task1 -nogui -ni -p $PROJ \
          epochs=$EPOS  batches=$BATCH  n_threads=$THRD \
          arch=$ARCH  data_set=$DSET  fldTag=f$FOLDSET
   fi
done

unless there are other/better suggestions.

LMHmedchem
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

background problem in while loop

file 005: trap 'echo "\nInterrupcion recibida.Saliendo\n\n" ; exit 0 ' 2 9 15 while true do ./005.aux & done 005.aux: trap 'exit 0' 2 9 15 sleep 30 exit 0 The error ocurrs if i try to execute 005.aux in background. How could i resolve it? Thanks :cool: (7 Replies)
Discussion started by: Jariya
7 Replies

2. Shell Programming and Scripting

Repetitive Tasks: using if..then inside a loop

I thought I was getting pretty good with Bash but this problem is stumping me. Any suggestions would be greatly appreciated. I've written a firewall script that uses a lot of functions. The variables are read into the script from another .conf file earlier on in the code. Most of these... (2 Replies)
Discussion started by: garak
2 Replies

3. Shell Programming and Scripting

background processing in BASH

I have script 3 scripts 1 parent (p1) and 2 children child1 and child2 I have script 3 scripts 1 parent 2 children child1 child2 In the code below the 2 child processes fire almost Instantaneously in the background, Is that possible to know the status of pass/fail of each process... (12 Replies)
Discussion started by: jville
12 Replies

4. Shell Programming and Scripting

kill PID running in background in for loop

Guys, can you help me in killing the process which is running in back ground under for loop I am not able to find the PID using ps -afx|grep <word in command I entered> (1 Reply)
Discussion started by: mohan_xunil
1 Replies

5. Shell Programming and Scripting

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... (1 Reply)
Discussion started by: meetvipin
1 Replies

6. Shell Programming and Scripting

Doing multiple tasks in a loop.

I am in the process of updating a folder of hundreds of recipe html files. I've already managed to modify a number of things in each file but I have run into something that's beyond my ability. I have a text file that I need to insert the contents into the html at a specific point. It creates... (0 Replies)
Discussion started by: Trapper
0 Replies

7. 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

8. Shell Programming and Scripting

While loop hangs in function running in background

Hello Everyone, I am writing a shell script to fetch log files from remote servers within a time range. It copies log files to local server, grep for date and then compares the time stamp of each log entry with the once specified. Below is the code. # Get log and Parsing function ... (1 Reply)
Discussion started by: kanagalamurali
1 Replies

9. Shell Programming and Scripting

Bash script parallel tasks and command to wait untill complete?

Hello, im having bash script with while *** command1 && command2 && command3 && done i want to ask how i can prevent overloading server, by waiting untill all commands complete? any low resources intensive command like "wait" - i dont know if exist? (2 Replies)
Discussion started by: postcd
2 Replies
ARCH(1) 							   User Commands							   ARCH(1)

NAME
arch - print machine hardware name (same as uname -m) SYNOPSIS
arch [OPTION]... DESCRIPTION
Print machine architecture. --help display this help and exit --version output version information and exit AUTHOR
Written by David MacKenzie and Karel Zak. REPORTING BUGS
Report arch bugs to bug-coreutils@gnu.org GNU coreutils home page: <http://www.gnu.org/software/coreutils/> General help using GNU software: <http://www.gnu.org/gethelp/> Report arch translation bugs to <http://translationproject.org/team/> COPYRIGHT
Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. SEE ALSO
uname(1), uname(2) The full documentation for arch is maintained as a Texinfo manual. If the info and arch programs are properly installed at your site, the command info coreutils 'arch invocation' should give you access to the complete manual. GNU coreutils 8.5 February 2011 ARCH(1)
All times are GMT -4. The time now is 12:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy