![]() |
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 |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to wait for the subprocess to finish in tcl | nathgopi214 | Shell Programming and Scripting | 1 | 03-26-2008 09:40 AM |
| how do i finish this last one.. | newby2 | UNIX for Dummies Questions & Answers | 2 | 01-18-2008 11:52 AM |
| wait for 5 seconds in shell script | gopsman | Shell Programming and Scripting | 2 | 08-30-2007 05:47 AM |
| Need to execute 2 scripts, wait, execute 2 more wait, till end of file | halo98 | Shell Programming and Scripting | 1 | 08-01-2006 04:42 PM |
| wait in shell scripts | Vinaya | Shell Programming and Scripting | 1 | 09-23-2004 08:29 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
How can I wait for PID to finish in another shell
Have a need to schedule programs that can run after other programs are completed. Here's the catch:
1) The list of programs will not always be the same (kind of a plug-n-play deal) 2) The invoking shell may not be the same as the shell of the program being waited on In other words, I need to be able to wait on PID's from other shells in the same Unix box. I've looked through Unix in a Nutshell & Power Tools and found nothing. Any advice? |
|
||||
|
This is a script I wrote a long time ago and have been using since (not sure how widespread pgrep is, but this works in Solaris).
Code:
#!/bin/bash
# Variables
PROCESS="" # This is what you want to page on
MAILTO="" # Space delmited list of email addresses
HOSTNAME=`hostname`
A=1
# Processing
until [ ${A} -eq 2 ]; do
pgrep -f "${PROCESS}" >/dev/null 2>&1
if [ $? -eq 0 ]; then
sleep 300
else sleep 30
pgrep -f "${PROCESS}" >/dev/null 2>&1
FLAG=$?
if [ ${FLAG} ! -eq 0 ]
then echo "$PROCESS is no longer running on ${HOSTNAME}" | mailx -s "
${PROCESS}" ${MAILTO}
A=2
exit 0
fi
fi
done
I know this isn't exactly what you are looking for, but you should be able to modify it to work (sorry, I have been at work too long today to do it). |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|