Pause a script

Dave Ihnat dihnat at dminet.com
Tue Feb 6 15:13:42 UTC 2007


On Tue, Feb 06, 2007 at 09:57:16AM -0500, Mark Haney wrote:
> I'm not sure this will help.  Here's the situation:
> 
> script1 - checks for the existence of test.pid
> script2 - the job that actually will create the pid

I'm answering this, instead of the original request, since you actually
described what you're trying to do more clearly here.

There are several ways to do this, but probably the simplest is to put the
following code snippet into your script1 (modify as appropriate for your
environment, of course):

  PIDFILE=/var/state/app/test.pid	# Or wherever, of course
  RETRY_INTERVAL=10;
  MAX_RETRIES=10;

  RETRY_COUNT=0;

  while [ $RETRY_COUNT -le $MAX_RETRIES ]
  do
  	if [ ! -f $PIDFILE ]
	then
		let RETRY_COUNT=$RETRY_COUNT+1;
		sleep $RETRY_INTERVAL;
	else
		break;
	fi;
  done;

There are more elegant approaches, of course--using a named pipe would be
the simplest of those--but this will work.

Cheers,
--
	Dave Ihnat
	President, DMINET Consulting, Inc.
	dihnat at dminet.com




More information about the fedora-list mailing list