Solaris / OpenSolarisThis forum is for the discussion of Solaris and OpenSolaris.
General Sun, SunOS and Sparc related questions also go here.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I need to copy 1.3TB to two drives. I have two drives, called Movies1 and Movies2. Each drive is one zpool. Thus, I have two zpools. I want identical copies of my 1.3TB data. I want to do one command at a time, and not simultaneous:
# zfs send tank/Video@now | zfs receive Movies1/now1
# zfs send tank/Video@now | zfs receive Movies2/now2
I do not want to do them simultaneously. I want to do one copy, and when it has finished copying, I want to start the next copy. So how do I do that?
If I write both lines into a shell file and execute the shell, then the first command will execute and return after 1 second, and then the other command will execute 1 second later? I want the first command to execute, which may take 2 hours, and then the other command to execute. How can I do that?
Actually, I want to do this:
# zfs send tank/Video@now | zfs receive Movies1/now1
# zfs scrub Movies1
# zfs send tank/Video@now | zfs receive Movies2/now2
# zfs scrub Movies2
But I do not want the copying to be simultaneous. As soon as the first "zfs..." ends, I want "zfs scrub" to start and immediately I want the second "zfs..." to start. So Movies1 will be scrubbed while I copy again.
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 854
Thanked: 34
If you end the line with a semicolon, that means that command should finish before proceeding. I typically use that in ksh, but I'm pretty sure it should apply to sh as well.
You could also put '&& \' at the end of the lines. That's different, and says, if this command succeeds then proceed. Of course the "\" is just continuing the lines so that the next command is considered as a continuation of the first line.
Thanks. I did something like
command1 & command2 ; command3 & command4 ; command5 & command6
on one big line. This means that command1 and command2 will be performed simultaneuosly. And then, when they have finished, command3 and command4 will start. commmand3 and command4 will wait until their turn.
Distribution: Solaris & OpenSolaris based distros, Ubuntu
Posts: 8,134
Thanked: 86
Note that a trailing semicolon has no particular effect.
The shell executes the commands sequentially so doesn't start running a command before the previous one has finished (daemons, background and pipelines commands excepted).
If you write a shell script like (I have no idea what these commands do, BTW)
Code:
zfs send tank/Video@now
zfs scrub Movies1
Then the script will wait until the first returns and then execute the second command, it's as simple as that.
It gets complicated if the first command returns before it completes (for example it backgrounds itself or turns itself into a daemon) or if you want execution of the second command to be conditional on the first command succeeding or failing -- but if you want "normal" commands to be executed in sequence then just put them one after another in the script.
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 854
Thanked: 34
OK, I have two senior members, both of whom I typically trust, telling me I'm wrong.
I tried researching it today (searching through the O'Reilly book "Learning the Korn Shell", as well as putting my google fu to the test), and couldn't find anything to support what I had said. My boss, who is a Unix guru going way back, has said this many times ("the semicolon forces completion"), and I could swear we have had problems with cron scripts where putting in all the semicolons fixed it. But, hey, there's enough uncertainty in all that and nothing concrete to prove me right. So I guess I have to concede.
If I ever find anything concrete in my favor, I'll come back here with a link. But, that doesn't seem likely at the moment.
OK, I have two senior members, both of whom I typically trust, telling me I'm wrong.
Thanks but take care -- I don't trust me!
But the GNU Bash Reference Manual is definitive (until proven wrong!). It says "Note that wherever a ‘;’ appears in the description of a command's syntax, it may be replaced with one or more newlines".
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 854
Thanked: 34
Lucky. Paper I published in 1984 (http://deepblue.lib.umich.edu/handle/2027.42/24683). My co-author is very active in mathematical publishing. Sometime around 2000 or so, he published a paper with someone who had an Erdös 2. That gave him a 3 and me a 4. Just a lucky shot out of the blue.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.