Sponsored Content
Top Forums Shell Programming and Scripting Loop to run commands - after the previous instance completed Post 303014107 by neil.k on Monday 5th of March 2018 10:49:58 AM
Old 03-05-2018
Loop to run commands - after the previous instance completed

Hi All,

I am trying to call a shell script in a loop. I want my first instance to complete, and then the 2nd instance of the command to start - and so on.

eg. I am running this script 30 times. The wrapper script needs business date, from_time,to_time & server_name as inputs.

Code:
script_name businees_date from_time to_time server_name
--------------------------------------------------------
wrapper.sh "20180305" "09:30:00" "09:30:59" P6
wrapper.sh "20180305" "09:31:00" "09:31:59" P6
wrapper.sh "20180305" "09:32:00" "09:32:59" P6

The wrapper script takes almost 8-10 minutes to execute per run.

With my below code, it calls the wrapper script "n" times, without waiting for the previous instance of the command to complete.
How do I make the 1st instance of the wrapper to finish, before the 2nd gets called - and so on.

Code:
bdate=`date +%Y%m%d`
server_name=P6
script='wrapper.sh'
config=min_by_min.txt

while read -r from_time to_time; do
$script $bdate $from_time $to_time $server_name
done < $config

The config file looks like this.
Code:
$head -4 min_by_min.txt
"09:30:00" "09:30:59"
"09:31:00" "09:31:59"
"09:32:00" "09:32:59"
"09:33:00" "09:33:59"

Can you guys please help?

Last edited by rbatte1; 03-06-2018 at 08:11 AM.. Reason: Added CODE tags round the input/output
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Can I use history command to run previous commands?

Hi, I can use history command in unix to view my last 50 commands. But how can I run the previous commands easily? Can history command help? Firebird (2 Replies)
Discussion started by: firebirdonfire
2 Replies

2. Solaris

previous commands using UPARROW key

What settings should be done in order make UPARROW key to show previous commands on the shell prompt(Solaris)? (6 Replies)
Discussion started by: shafi2all
6 Replies

3. Shell Programming and Scripting

[PHP] endless loop mimics a cron. Make sure only one instance is running

Hi, PHP user here. I'm using an endless loop to perform to mimic a cron. The script does something every 20 minutes. It sleep()s in the meantime. I have various checks that ensure that only instance can run, including a "gentleman agreement" locked file. However, I'd like to make sure... (2 Replies)
Discussion started by: jjshell
2 Replies

4. Solaris

How can I output all previous Unix commands in Solaris to a file??

Hello friends: I login to solaris with a username/Password and I can see quite a lot of previous I use dbefore, it accumulates a lot, I hope to output them into a Command.txt file as reference, not copy/paste 1 by 1, is there any way I can collect all commands in batch then put into a file, ... (3 Replies)
Discussion started by: sunnysunnysunny
3 Replies

5. Shell Programming and Scripting

How to run the following expect commands in a loop

#!/usr/bin/expect spawn telnet 1.1.1.1 expect login* send “admin\r” expect Password* send “abcdef123\r” expect “Router#” send “exit\r” I want the above code to run in a loop such that script keeps doing a telnet to the device. Please suggest Tarun (1 Reply)
Discussion started by: tkhanna82
1 Replies

6. Shell Programming and Scripting

Script not checking previous instance run

Hi All, I have developed :D a script that should run only if previous instance has stopped . But illogically :o my script runs even if previous instance is running .I am not sure :confused: what is going wrong :wall: , please help. #!/bin/ksh HOME=/fs159/Purgingbackup/UPW/Purging... (2 Replies)
Discussion started by: dhirajdsharma
2 Replies

7. Shell Programming and Scripting

UP arrow button to recall previous commands in Putty

Hi, I remember in my previous project, I used UP arrow button to recall previous unix commands (using putty on Sun OS), which I am not able to do in my new project... I do not know if this is some project specific settings or not... when I press UP arrow button, all I get is ^. I have to... (3 Replies)
Discussion started by: juzz4fun
3 Replies

8. Shell Programming and Scripting

How to run the following expect commands in a loop?

spawn fbat expect ">>" send "log fbatPW80_OR8sim1 \r" expect ">>" send "load map.map \r" expect ">>" send "load fbatPW80_OR8sim1.ped \r" expect ">>" send "fbat -v1 \r" expect ">>" send "log off \r" expect ">>" I need the above code to run in a loop such that script keeps doing a... (1 Reply)
Discussion started by: zoeli
1 Replies

9. Shell Programming and Scripting

Logrotate.d for every httpd instance for loop?

/etc/logrotate.d -rwxr-xr-x 1 root root 263 Aug 28 23:17 httpd-stooffsprod -rwxr-x--- 1 root root 273 Jul 10 2015 httpd-mwsi2hprodhist2 -rwxr-x--- 1 root root 261 Aug 11 17:28 httpd-mwsihist2 -rwxr-x--- 1 root root 269 Jul 20 2015 httpd-mwsiprodhist2 I need to figure out how to build a... (14 Replies)
Discussion started by: xgringo
14 Replies

10. Shell Programming and Scripting

Run rest of script after parallel steps have completed

Hello gurus, I produce a number of .loc files in parallel depending on number of .csv in the folder for file in *csv do ./process.sh $file > $file.loc & done then I want to compile all the output from the previous step into a single masterlocfile and then perform the rest of the steps... (2 Replies)
Discussion started by: senhia83
2 Replies
asadmin-stop-instance(1AS)					   User Commands					asadmin-stop-instance(1AS)

NAME
asadmin-stop-instance, stop-instance - stops the specified server instance and all the services associated with it SYNOPSIS
stop-instance [--user admin_user] [--password admin_password] [--host local_host] [--port 4848] [--local=false] [--domain domain_name] [--secure|-s]instance_name Use the stop-instance to stop the instance with the instance name specified. The stop-instance can be run both locally and remotely. The named instance must already exist within the given domain; and the instance must be running. OPTIONS
--user administrative user associated for the instance. --password administrative password corresponding to the administrative user. --host host name of the machine hosting the administrative instance. --port administrative port number associated with the administrative host. --local determines if the command should delegate the request to administrative instance or run locally. --domain name of the domain. --passwordfile file containing passwords appropriate for the command (e.g., administrative instance). --secure if true, uses SSL/TLS to communicate with the administrative instance. OPERANDS
instance_name name of the instance to be stopped. Example 1: Using stop-instance in local mode asadmin> stop-instance --local --domain domain1 server1 Instance server1 stopped Where: the server1 instance associated with the domain1 domain is stopped locally. Example 2: Using stop-instance in remote mode asadmin> stop-instance --user admin --password bluestar --host localhost --port 4848 server1 Instance server1 stopped Where: the server1 instance associated with the named user, password, host and port is deleted from the remote machine. EXIT STATUS
0 command executed successfully 1 error in executing the command INTERFACE EQUIVALENT
Server Instance page asadmin-delete-instance(1AS), asadmin-start-instance(1AS), asadmin-create-instance(1AS), asadmin-restart-instance(1AS), asadmin-start- appserv(1AS), asadmin-stop-appserv(1AS), asadmin-start-domain(1AS), asadmin-stop-domain(1AS) J2EE 1.4 SDK March 2004 asadmin-stop-instance(1AS)
All times are GMT -4. The time now is 05:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy