Script to read file and run multiple jobs


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to read file and run multiple jobs
# 1  
Old 10-24-2017
Script to read file and run multiple jobs

I have a txt file

Code:
line1
line2
line3

Code:
$!/bin/sh
cat /tmp/lus.txt | while read line
do
esxcli storage vmfs unmap -u $lin -n 4000
done

this works but does in one line at a time.

how do I do all lines at once simutaeously?


Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 10-24-2017 at 12:39 PM.. Reason: Added CODE tags.
# 2  
Old 10-24-2017
Code:
#!/bin/sh
while read line
do
   esxcli storage vmfs unmap -u $line -n 4000 &
done < /tmp/lus.txt
wait     # (or not)

# 3  
Old 10-24-2017
can you explain? what is wait for?

---------- Post updated at 09:18 AM ---------- Previous update was at 09:15 AM ----------

is this going to run all 30 lines at once?

Code:
esxcli storage vmfs unmap -u $line -n 4000 &


Moderator's Comments:
Mod Comment
Please wrap all code, files, input & output/errors in CODE tags.
It makes it easier to read and preserves spaces for indenting or fixed-width data.

Last edited by rbatte1; 10-24-2017 at 01:40 PM.. Reason: Added CODE tags
# 4  
Old 10-24-2017
The wait command will not complete until all background processes for this shell have ended. This means your script will spawn all your 30 (or whatever) esxcli commands and then hang until they complete so you know when to carry on. If you don't want this to happen, simply remove the wait




Robin
# 5  
Old 10-24-2017
esxi

does esxi support running & jobs in the bg?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to run multiple cron jobs?

I have two scripts which I'm tying to run one after the other- this is what I've tried: 00 14 * * * /path/one.sh && /path/two.sh I've also tried putting each script on a different line: 00 14 * * * /path/one.sh 00 14 * * * /path/two.sh Can this be done? (1 Reply)
Discussion started by: $shell_Learner
1 Replies

2. Shell Programming and Scripting

Read xml file till script finds separation and run again for next input and so on

Hi All, I have one query, I managed to run script with user inputs through command line or with 1 file. But I need to read a txt file/xml file in which user can mention multiple sets of answers and script should run for each set till it reach the EOF. Thanks in advance for example, the file... (3 Replies)
Discussion started by: rv_champ
3 Replies

3. Shell Programming and Scripting

Shell script to run multiple jobs and it's dependent jobs

I have multiple jobs and each job dependent on other job. Each Job generates a log and If job completed successfully log file end's with JOB ENDED SUCCESSFULLY message and if it failed then it will end with JOB ENDED with FAILURE. I need an help how to start. Attaching the JOB dependency... (3 Replies)
Discussion started by: santoshkumarkal
3 Replies

4. Shell Programming and Scripting

Script to read a log file and run 2nd script if the dates match

# cat /tmp/checkdate.log SQL*Plus: Release 11.2.0.1.0 Production on Mon Sep 17 22:49:00 2012 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production FIRST_TIME NEXT_TIME... (1 Reply)
Discussion started by: SarwalR
1 Replies

5. Shell Programming and Scripting

Script to run command against multiple specific value in one file

Hi all, I am trying to create a shell script from solaris 10 server to run a command into multiple specific value in one file. The command is related to Oracle/Sun JES2005Q4 directory server. #this is the command, #from path /jes/ds/slapd-rldap1 ./ns-inactivate.pl -h mldap1 -p 389 -D... (12 Replies)
Discussion started by: Mr_47
12 Replies

6. Shell Programming and Scripting

Run perl script with multiple file arguments

Hello everyone, I have two types of files in a directory: *.txt *.info I have a perl script that uses these two files as arguments, and produces a result file: perl myScript.pl abc.txt abc.xml How can I run this script (in a "for" loop , looping through both types of files)... (4 Replies)
Discussion started by: ad23
4 Replies

7. Shell Programming and Scripting

General Q: how to run/schedule a php script from cron jobs maybe via bash from shell?

Status quo is, within a web application, which is coded completely in php (not by me, I dont know php), I have to fill out several fields, and execute it manually by clicking the "go" button in my browser, several times a day. Thats because: The script itself pulls data (textfiles) from a... (3 Replies)
Discussion started by: lowmaster
3 Replies

8. Shell Programming and Scripting

1 script or multiple scripts?? - check files, run jobs

Question for anyone that might be able to help: My objective is to eheck if a file (a source file) exists in a directory. If it does then, I'd like to call an application (Informatica ETL file...not necessary to know) to run a program which extracts data and loads it into multiple targets. ... (6 Replies)
Discussion started by: jnanasakti
6 Replies

9. Shell Programming and Scripting

background jobs exit status and limit the number of jobs to run

i need to execute 5 jobs at a time in background and need to get the exit status of all the jobs i wrote small script below , i'm not sure this is right way to do it.any ideas please help. $cat run_job.ksh #!/usr/bin/ksh #################################### typeset -u SCHEMA_NAME=$1 ... (1 Reply)
Discussion started by: GrepMe
1 Replies

10. Shell Programming and Scripting

How to write a Script to run series of batch jobs on unix platform

Im new to unix shell scripting, I have to run batch jobs on unix. for example i have 5 jobs. first 2 can kickoff parallely. after completely finishing the 2 previous jobs the 3 job should kick off..once 3rd is over 4 th and 5th can kick off parallely. Each jobs run for 1 or 2 hours each. How to... (2 Replies)
Discussion started by: venki311
2 Replies
Login or Register to Ask a Question