?
Solved

Using Enq in shell scripts

Posted on 1998-11-14
1
Medium Priority
?
254 Views
Last Modified: 2008-03-10
I need to write a shell script that starts several parallel processes in the background. Then it must wait untill all of them are finished. After that it must continue its operation.
I'm not sure if I can manipulate with semafores in shell script. Is it possible? If yes I'd like to get a code example.
If semafores are not accessible in a shell script, what would be the best way to implement this enqueue logic?
0
Comment
Question by:mgokman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 51

Accepted Solution

by:
ahoffmann earned 300 total points
ID: 2007842
There is no access to semaphores from within shell scripts without using other tools (perl, tcl).

But you may simply start your sub-processes in background and the check in a loop if there still some running using:

    jobs

NOTE that  jobs  may not list what you want if your started process is a deamon which detaches itself from the controlling terminal.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses
Course of the Month14 days, 10 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question