Bash: Regulating the number of processes a script can spawn


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Bash: Regulating the number of processes a script can spawn
# 8  
Old 05-08-2010
achenle,
your approach looks very promising, but I have following questions:

1. What does "set -bm" stand for?
2. How does the flow look like? There are two variants I can think of:
Let's assume every job will run for 5 minutes and let's forget about that SIGCHLD thing.
2.a It starts with line 20, the function startjob is called, "started=$(($started+1))" does *NOT* take effect, 1st job gets started, $count=1, line 20 calls the startjob function again ................................. $count=100 !! All 100 jobs are running at the same time.
2.b It starts with line 20, the function startjob is called, $started=1, 1st job gets started, $count=1, .... Script ends after 10 jobs, because $started=10.
3. IMHO that "wait" line is pretty unnecessary (pls. correct me if I'm wrong)

Is there an error in the way I think how it will work Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

(bash) Script Processes in Parallel

Hello all, I tried to parralise my treatments but after a while 'ps -ef' display all child process <defunct> (zombie) Parent bash script to process all files (>100000) in directory: for filename in /Data/*.txt; do ./child_pprocess.sh $filename & done exit(0)I understand that the... (1 Reply)
Discussion started by: namnetes
1 Replies

2. Shell Programming and Scripting

Is it possible to Divide a negative number in bash script

I am using a small script to divide some numbers in a given file and display the output in another file. I am getting the following error basename: invalid option -- '5' Try `basename --help' for more information. (standard_in) 1: syntax error The script is : #!/bin/bash for i in `cat... (4 Replies)
Discussion started by: kmnr877
4 Replies

3. Shell Programming and Scripting

SPAWN Multiple Processes in Unix

Hi, I have three files in my IN directory.Each file should be copied 25 times using for loop.Each file processing should run in parallel?How to spawn multiple processes in unix?Any help would be appreciated. Thanks, Liyakath (7 Replies)
Discussion started by: liyakathali
7 Replies

4. Shell Programming and Scripting

script for multi-threaded bash processes

hey everyone, I'm having some trouble breaking down some code. It's simple a control script that takes machines meant to be backed up from a list. Then according to that will run multi-threaded processes up until the specified thread limit. for example if there are 4 machines to be backed up,... (2 Replies)
Discussion started by: terrell
2 Replies

5. Shell Programming and Scripting

need to kill a number of processes with name "XYZ" at a time using shell script

Hi, when i grep for the process "XYZ" , there will be some good number of processes with that name, i want to kill all the these processes at a time using shell script? Any help needed for this action. Thanks Regards, Anil (6 Replies)
Discussion started by: anilmanepu
6 Replies

6. Shell Programming and Scripting

Printing the line number in bash script

Hi, I would like to know how do I print the line # in a script. My requirement is, I have a script which is about ~5000 lines long. If there are any errors happen I just exit. And I would like to add the line # of the script where the error happened. Thanks, (6 Replies)
Discussion started by: suryaemlinux
6 Replies

7. Shell Programming and Scripting

Defining Dynamic Number of Variables in a Bash Script

Code: $ cat test.bash #!/bin/bash job=$1 steps=$2 num=$(echo "$@" | wc -w) Example Submission: $ ./test.bash BS01 3 1 2 3 What: (2 Replies)
Discussion started by: mkastin
2 Replies

8. Programming

Program to spawn multiple processes

I'm trying to make a program that will spawn multiple child processes then exit. I'm having trouble figuring out how to do this since after I fork, the child process begins running the program again (never ending). int main(void){ for(int i = 0; i < 3; i++){ fork(); }... (1 Reply)
Discussion started by: cagney58
1 Replies

9. Shell Programming and Scripting

shell script for getting pid of spawn processes from shell

Hi, I am new this forum. I request you peoples help in understanding and finding some solution to my problem. Here it goes: I need to perform this set of actions by writing a shell script. I need to read a config file for the bunch of processes to execute. I need to fecth the pid of... (4 Replies)
Discussion started by: sachin4sachi
4 Replies

10. Programming

Howto spawn multiple child processes and wait?

As far as I can tell, the bash wait command waits for a logical "AND" of all the child processes. Assuming I am coding in C: (1) What is the function I would use to create multiple bash child process running perl? (2) What is the function I would use to reinvent the bash wait command so I... (4 Replies)
Discussion started by: siegfried
4 Replies
Login or Register to Ask a Question
spawn-fcgi(1)						      General Commands Manual						     spawn-fcgi(1)

NAME
spawn-fcgi - Spawns FastCGI processes SYNOPSIS
spawn-fcgi [options] [ -- <fcgiapp> [fcgi app arguments]] spawn-fcgi -v spawn-fcgi -h DESCRIPTION
spawn-fcgi is used to spawn remote and local FastCGI processes. While it is obviously needed to spawn remote FastCGI backends (the web server can only spawn local ones), it is recommended to spawn local backends with spawn-fcgi, too. Reasons why you may want to use spawn-fcgi instead of something else: * Privilege separation without needing a suid-binary or running a server as root. * You can restart your web server and the FastCGI applications without restarting the others. * You can run them in different chroot()s. * Running your FastCGI applications doesn't depend on the web server you are running, which allows for easier testing of other web servers. OPTIONS
spawn-fcgi accepts the following options: -f <path> Filename of the FastCGI application to spawn. This option is deprecated and it is recommend to always specify the application (absolute path) and its parameters after "--"; the fcgiapp parameter is directly used for the exec() call, while for starting the binary given with -f /bin/sh is needed (which may not be available in a chroot). This option is ignored if fcgiapp is given. -d <path> Change the current directory before spawning the application. -a <address> IPv4/IPv6 address to bind to; only used if -p is given too. Defaults to "0.0.0.0" (IPv4). -p <port> TCP port to bind to; you cannot combine this with the -s option. -s <path> Path to the Unix domain socket to bind to; you cannot combine this with the -p option. -C <children> (PHP only) Number of children to spawn by setting the PHP_FCGI_CHILDREN environment variable. Default is not to overwrite the envi- ronment variable; php will spawn no children if the variable is not set (same as setting it to 0). -F <children> Number of children to fork, defaults to 1. This option doesn't work with -n, have a look at multiwatch(1) if you want to supervise multiple forks on the same socket. -P <path> Name of the PID file for spawned processes (ignored in no-fork mode) -n No forking should take place (for daemontools) -M <mode> Change file mode of the Unix domain socket; only used if -s is given too. -?, -h General usage instructions -v Shows version information and exits The following options are only available if you invoke spawn-fcgi as root: -c <directory> Chroot to specified directory; the Unix domain socket is created inside the chroot unless -S is given. -S Create Unix domain socket before chroot(). -u User ID to change to. -g Group ID to change to. Defaults to primary group of the user given for -u. -U Change user of the Unix domain socket, defaults to the value of -u. (only used if -s is given) -G Change group of the Unix domain socket, defaults to the primary group of the user given for -U; if -U wasn't given, defaults to the value of -g. (only used if -s is given) SEE ALSO
svc(8), supervise(8), see http://cr.yp.to/daemontools.html multiwatch(1), see http://cgit.stbuehler.de/gitosis/multiwatch/about/ 26 March 2009 spawn-fcgi(1)