In this article i will explain how you can run commands in parallel and make sure you wait until all commands and have finished and then move forward.
Say you have a script which downloads few files or yu have to compile different maven project(independent of each other) or something else which can run in parallel and you have got a good machine which can run these tasks in parallel so that overall you can run the full task in lowest time.
For this you can use back ground task and wait from unix.
When you add & to any command that command runs in background
What is wait command?
wait is a built-in command of Linux that waits for completing any running process. wait
command is used with a particular process id or job id. When multiple
processes are running in the shell then only the process id of the last
command will be known by the current shell. If wait command is executed
this time, then it will be applied for the last command.
If no process
id or job id is given with wait command then it will wait for all
current child processes to complete and returns exit status.
Here goes an example
echo First Group: command A & command B & command C & wait #Command D will not run untill Command A,B, C all finished echo Second Group: command D & command E & wait #Command F will not run untill Command A,B, C,D and E all finished command F
I like your all post. You have done really good work. Thank you for the information you provide, it helped me a lot. I hope to have many more entries or so from you.
ReplyDeleteVery interesting blog.visit my wepsite https://vstking.net/
JetBrains PhpStorm Crack
Resolume Arena crack
SmartDraw crack
Wondershare Filmora crack