![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to know a executable has finished his task | electroon | Shell Programming and Scripting | 4 | 01-04-2008 02:12 AM |
| ** Finished ** Syncid.rc | syndex | Shell Programming and Scripting | 1 | 07-10-2007 10:18 AM |
| background job finished notification | nkeller | UNIX for Dummies Questions & Answers | 4 | 03-08-2007 12:41 PM |
| Has my script finished? | Bab00shka | UNIX for Dummies Questions & Answers | 5 | 07-23-2002 09:39 AM |
| Finding Out When A Process Has Finished? | 1cuervo | UNIX for Advanced & Expert Users | 5 | 11-02-2001 05:59 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
How do I know all processes are finished?
Hi all,
I am writing a C shell script that starts a program. The program forks of several child processes. Only when all child processes are done, I want to archive my log files. Below is what I have so far, but unfortunately it doesn't work. MyProgram if (-e processes.txt) then rm processes.txt endif ps -C MyProgram | grep MyProgram > processes.txt while (-s processes.txt) rm processes.txt ps -C MyProgram | grep MyProgram > processes.txt rm processes.txt # start archiving log files The while loop is done twice and than the archiving starts, while one of the child processes is still running. Does anyone know what I am doing wrong or does anyone have any other suggestion on how to do this? Thanks a lot. |
|
||||
|
Your best bet is to have each fork generate and then remove a lockfile of their own upon start and exit. The parent process or some other process can then monitor these for status and run the archive process when all of the lockfiles are gone. Something like while [ -e $lockfdir/$lockfile ] or sleep then check an ls command's $? for 0 would probably work ...
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|