Solved

Using Enq in shell scripts

Posted on 1998-11-14
1
232 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
1 Comment
 
LVL 51

Accepted Solution

by:
ahoffmann earned 100 total points
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
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 how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now