LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > CentOS
User Name
Password
CentOS This forum is for the discussion of CentOS Linux. Note: This forum does not have any official participation.

Notices


Reply
  Search this Thread
Old 09-25-2015, 04:49 AM   #1
robertkwild
Member
 
Registered: Feb 2015
Posts: 382

Rep: Reputation: Disabled
shell - do i need a wait command


hi all,

i have made a shell script but i need to know if i need a wait command in-between my commands, because the first command takes ages to copy over something (about 5 minutes) and the next command is the next line, so will it not complete the copy off?

many thanks

rob
 
Old 09-25-2015, 04:55 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Shell commands are, unless they get executed in the background or otherwise handed off (say 'at' service), executed sequentially.
 
Old 09-25-2015, 05:57 AM   #3
robertkwild
Member
 
Registered: Feb 2015
Posts: 382

Original Poster
Rep: Reputation: Disabled
so should i put in a wait command in-between, whats the command syntax?
 
Old 09-25-2015, 06:35 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,039

Rep: Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347
no, you should not do that. The normal flow means every command will wait for the previous to complete. So you do not need to do anything. But probably you started some background processes, which will run independently and therefore you need to check if that one already completed or not. Without knowing your script we assume you have no backround jobs and therefore all the commands will be executed strictly one by one, one after another...
 
1 members found this post helpful.
Old 09-25-2015, 06:41 AM   #5
robertkwild
Member
 
Registered: Feb 2015
Posts: 382

Original Poster
Rep: Reputation: Disabled
vim-cmd vmsvc/power.shutdown VMID
mkdir /vmfs/volumes/datastore1/clone
vmkfstools -i /vmfs/volumes/datastore1/source/server.vmdk /vmfs/volumes/datastore1/dest/clone/server.vmdk
**the above line the copy is quite a long time as its copying a virtual hard drive**
cp /vmfs/volumes/datastore1/source/server.vmx /vmfs/volumes/datastore1/dest/clone
vim-cmd solo/registervm /vmfs/volumes/datastore1/dest/clone/server.vmx
vim-cmd vmsvc/power.on VMID
 
Old 09-25-2015, 07:29 AM   #6
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
i believe wait is not necessary; please post the output of your modified script below:
Quote:
Originally Posted by robertkwild View Post
Code:
vim-cmd vmsvc/power.shutdown VMID
mkdir /vmfs/volumes/datastore1/clone
echo schneidz-debug: callling vmkfstools -- waiting for it to complete
vmkfstools -i /vmfs/volumes/datastore1/source/server.vmdk /vmfs/volumes/datastore1/dest/clone/server.vmdk
echo schneidz-debug: returning from vmkfstools -- complete
#**the above line the copy is quite a long time as its copying a virtual hard drive**
echo schneidz-debug: continuing with copy
cp /vmfs/volumes/datastore1/source/server.vmx /vmfs/volumes/datastore1/dest/clone
vim-cmd solo/registervm /vmfs/volumes/datastore1/dest/clone/server.vmx
vim-cmd vmsvc/power.on VMID
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
make shell script wait and send signal to recover it esolve Programming 4 11-04-2012 12:58 AM
Shell script: How to wait on two processes at the same time dbrazeau Programming 16 03-18-2010 12:33 PM
How to make shell script wait for key press to proceed... ddenton Linux - General 13 12-02-2008 04:25 AM
Does Kornshell wait until one command completes before running the next command? ShaqDiesel Programming 4 09-10-2008 11:49 PM
Wait for one of two processes to complete in a shell script nonoitall Programming 11 06-10-2008 04:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > CentOS

All times are GMT -5. The time now is 06:04 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration