01-29-2010
My basic idea for solution would be to spawn initial N workes and save their pids to some table, then sleep 1 and see which of the PIDs are still alive. For those who are not - spawn next worker and save pid in place of the old one. Repeat until job is done.
The problem with counting with pgrep is that you will take in account the processess that may not be related with the script (any other user can run their own gzip, right?).
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I'm trying to install a solaris 9 patch cluster and when I try to use & to run in background it won't allow me to enter in my sudo password so it fails the install and sudo auth. Does Solaris not have screen like linux? If & will work what am I doing wrong?
sudo ./install_cluster -q &
is... (3 Replies)
Discussion started by: kingdbag
3 Replies
2. Shell Programming and Scripting
I have the following sample script to run a script the jobs with the same
priority(in this case field3) in parallel; wait for the jobs to finish
and run the next set of jobs in parallel.When all the lines are read
exit the script.
I have the following script which is doing evrything I want... (1 Reply)
Discussion started by: hyennah
1 Replies
3. Shell Programming and Scripting
i need to execute 5 jobs at a time in background and need to get the exit status of all the jobs i wrote small script below , i'm not sure this is right way to do it.any ideas please help.
$cat run_job.ksh
#!/usr/bin/ksh
####################################
typeset -u SCHEMA_NAME=$1
... (1 Reply)
Discussion started by: GrepMe
1 Replies
4. Shell Programming and Scripting
Hi All,
I have requirement. I am running a job every 30mins. before starting the process, i need to check the process, if the process is still running then i need not trigger the process again, if it is not running then trigger the process again. I am using cron to trigger the shell script. Can... (7 Replies)
Discussion started by: srinivas_paluku
7 Replies
5. Shell Programming and Scripting
Hello,
I am a novice shell script programmer. And facing this problem any help is appreciated.
I m writing a shell script and running few commands in it background as I have to run them simultaneously.
Sample code :
sql_prog &
sql_prog &
sql_prog &
echo "Process Completed"
Here... (2 Replies)
Discussion started by: vineetbhati
2 Replies
6. Shell Programming and Scripting
Hi,
I have on shell script which internally calls more than one scripts which run in background.
These scripts cannot be modified to run in foreground.
eg. myscript.sh -> bulk_launcher.sh -> acq_launcher.sh
-> bulk_loader.sh
I want the calling shell script myscript.sh to wait till the... (7 Replies)
Discussion started by: AB10
7 Replies
7. Shell Programming and Scripting
Hello,
I am running GNU bash, version 3.2.39(1)-release (x86_64-pc-linux-gnu). I have a specific question pertaining to waiting on jobs run in sub-shells, based on the max number of parallel processes I want to allow, and then wait... (1 Reply)
Discussion started by: srao
1 Replies
8. Shell Programming and Scripting
Hi ,
I want to see all the background process that are running in unix box machine...please guide me is there any specific command for that..since I am executing some scripts at background..!!:confused: (1 Reply)
Discussion started by: nks342
1 Replies
9. AIX
Hello,
Please advise use of screen in running jobs in nohup background and how to use this
Best regards,
Vishal (1 Reply)
Discussion started by: Vishal_dba
1 Replies
10. UNIX for Beginners Questions & Answers
Hi,
I have this simple c program that creates duplicate process with fork():
#include <sys/types.h>
main()
{
if (fork() == 0)
while(1);
else
while(1);
}
I tried running it in the background
gcc -o test first.c
test &
And I got this list of running process: (4 Replies)
Discussion started by: uniran
4 Replies
LEARN ABOUT FREEBSD
posix_spawnattr_setschedpolicy
POSIX_SPAWNATTR_GETSCHEDPOLICY(3) BSD Library Functions Manual POSIX_SPAWNATTR_GETSCHEDPOLICY(3)
NAME
posix_spawnattr_getschedpolicy, posix_spawnattr_setschedpolicy -- get and set the spawn-schedpolicy attribute of a spawn attributes object
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <spawn.h>
int
posix_spawnattr_getschedpolicy(const posix_spawnattr_t *restrict attr, int *restrict schedpolicy);
int
posix_spawnattr_setschedpolicy(posix_spawnattr_t *attr, int schedpolicy);
DESCRIPTION
The posix_spawnattr_getschedpolicy() function obtains the value of the spawn-schedpolicy attribute from the attributes object referenced by
attr.
The posix_spawnattr_setschedpolicy() function sets the spawn-schedpolicy attribute in an initialized attributes object referenced by attr.
The spawn-schedpolicy attribute represents the scheduling policy to be assigned to the new process image in a spawn operation (if
POSIX_SPAWN_SETSCHEDULER is set in the spawn-flags attribute). The default value of this attribute is unspecified.
RETURN VALUES
The posix_spawnattr_getschedpolicy() and posix_spawnattr_setschedpolicy() functions return zero.
SEE ALSO
posix_spawn(3), posix_spawnattr_destroy(3), posix_spawnattr_getschedparam(3), posix_spawnattr_init(3), posix_spawnattr_setschedparam(3),
posix_spawnp(3)
STANDARDS
The posix_spawnattr_getschedpolicy() and posix_spawnattr_setschedpolicy() functions conform to IEEE Std 1003.1-2001 (``POSIX.1'').
HISTORY
The posix_spawnattr_getschedpolicy() and posix_spawnattr_setschedpolicy() functions first appeared in FreeBSD 8.0.
AUTHORS
Ed Schouten <ed@FreeBSD.org>
BSD
March 24, 2008 BSD