Scripts to start and stop

Michael Kjorling michael at kjorling.com
Fri May 25 19:00:47 UTC 2001


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The $$ variable in Perl is the PID (apparently, my list of those isn't
here, and I've never used this one myself). So printing it to a file
from within the script would give you easy access to the currently
running nanny's PID. However, there is a caveat. You still have to
make sure THAT nanny is running at all, since this file is not deleted
when nanny.pl is killed. It is certainly possible to do that as well,
but it takes heavier modifications.

Also, you might want to close the PID file after writing to it, to be
sure that you don't leave that file open... and opening it for writing
and truncation wouldn't be too bad either. So I would consider adding
this to the top of the script if that is the way we'd do it:

open(PID, ">/var/run/nanny.pid") || die $!;
print PID $$;
close PID;


Michael Kjörling


On May 25 2001 14:43 -0400, Adam Lang wrote:

> Yeah, the w option fixes the truncating problem.
>
> How would nanny.pl create a nanny.pid file?  I assume there is something to
> grab the pid it generated?
>
> I'm sorry, but I do very little shell scripting... this is probably the most
> complicated one I've tried.
>
> Adam Lang
> Systems Engineer
> Rutgers Casualty Insurance Company
> http://www.rutgersinsurance.com
> ----- Original Message -----
> From: "Bill Larson" <wllarso at swcp.com>
> To: "Adam Lang" <aalang at rutgersinsurance.com>
> Cc: <bind-users at isc.org>
> Sent: Friday, May 25, 2001 2:29 PM
> Subject: Re: Scripts to start and stop
>
>
> > The output from the ps command is being truncated!  I believe that
> > there is also a "w" option to ps which will include more of the command
> > argument being reported (and maybe a "ww" also!).  Take a look at the
> > man page for ps.
> >
> > Another option could be to modify the nanny.pl command to record the
> > PID of the nanny command in a file, exactly the same idea as named
> > writing a named.pid file.  This could be done by adding the following
> > just prior to the being of the "for" loop:
> >
> > open(PID,"/var/run/nanny.pid");
> > print PID $$;
> >
> > This will give you a file, "/var/run/nanny.pid", which contains the
> > value of the PID of the nanny.pl script that is running.  You can
> > then use the value reported in this file for the PID to actually kill.
> >
> > Bill Larson

- -- 
Michael Kjörling - michael at kjorling.com - PGP: 8A70E33E
"We must be the change we wish to see" (Mahatma Gandhi)

^..^     Support the wolves in Norway -- go to     ^..^
 \/   http://home.no.net/ulvelist/protest_int.htm   \/

-----BEGIN PGP SIGNATURE-----
Version: PGP 6.5.8

iQA/AwUBOw6r5Sqje/2KcOM+EQJJ3QCfQTfvi4FgTPJ2VuiC1F1Zc/r//sIAniP3
P6/cPwzQZMfxdhgMxTZ7fq9R
=oSJH
-----END PGP SIGNATURE-----




More information about the bind-users mailing list