LiveFire Labs - Online UNIX Training - Company Logo


Online UNIX Training with Hands-on Internet Lab


"Eliminate the expense and inconvenience of classroom training without eliminating the classroom experience."

 


Home
Internet Lab
Console Access
Sample Course

Student Login


LiveFire Labs' UNIX Tip, Trick, or Shell Script of the Week - View


Questions? Call
1.888.843.1637 or send us email





Co-processes - Part V

Last week's tip presented you with a hypothetical data collection and processing requirement, and asked you to think about how it could be optimized for a large server environment using co-processes.

As mentioned last week, collecting a significant amount of data from each server in an environment containing many servers in a serial fashion (one after another) may not be an acceptable option, especially if the collecting and subsequent processing needs to be performed within a limited amount of time.  Running multiple co-processes from a parent script on the "master" system, with each co-process performing the data collection for one server in the environment, would be one possible option.

The most outer loop of the parent script could be a "for" or "while" loop, and would be used to cycle through each server (host) in the environment.  Within this loop, you would spawn a co-process for the server and bump your co-process counter.

This outer loop would also contain an inner loop used to read from each outstanding co-process when your co-process counter was equal to the max co-process variable.  After each outstanding co-process had been accounted for, the co-process counter would be re-initialized and this inner "harvesting" loop would not run again until the counter becomes equal to the max co-process variable again.

Once a co-process is started for the last host in the environment, code would need to be executed to account for any outstanding co-processes.  At this point the data could be consolidated/processed on the master system as needed.  Notice that the max co-process variable could be tweaked based on how much of a load you want to put on the master server, and how quickly you want the parent script to execute.

This is obviously a very high-level view of one potential solution, but it will hopefully get you thinking about how co-processes can be creatively used to enhance your shell scripts.







Learn more...
  

If you are new to the UNIX or Linux operating system and would like to learn more, you may want to consider registering for LiveFire Labs' UNIX and Linux Operating System Fundamentals online training course.

If you already have a solid grasp of the fundamentals but would like to learn more about the Korn shell and basic and advanced shell scripting, taking our Korn Shell Scripting course will be beneficial to you.

Our innovative hands-on training model allows you to learn UNIX by completing hands-on exercises on real servers in our Internet Lab.


More Tips...

· 
Popular UNIX Tips from the Past

spacer Box Border
 

Receive the UNIX Tip, Trick, or Shell Script of the Week by Email


First Name:


Email Address:






   1.888.843.1637

Home - Contact us - Company info - Privacy Statement   

 
©2002-2004 LiveFire Labs.  All rights reserved.
Linux® is a registered trademark of Linus Torvalds, author and developer of this public domain operating system.
UNIX® is a registered trademark of The Open Group in the United States and other countries.