SUMMARY: swatch startup in RC files

From: Gregory Coleman (coleman@library.ucsf.edu)
Date: Tue Feb 10 1998 - 19:29:47 CST


Once again, Sun Managers has proven its awesomeness. Original question is
at the end of this message. Much thanks to everybody who replied.
Answers varied; some were things that I had already tried (eg. just put it
in the background); others were general reference about start-up files.
The best answer for this situation in particular seems to be:

A) Run it in the background and redirect STDOUT to a file

or...

B) Use NoHUP (to daemon-ize...)

I was particularly impressed by the resolution offered by Bill Walker
<bill.walker@sfa.org.uk> who had done the work to figure out how to handle
the multiple 'tail -f' processes that Swatch spawns. Maybe not 'pretty' by
his own standards, but still effectual...I think it really helped me.

---from Bill--->
'stop')

   PID1=`/usr/bin/ps -e -u 1 | /usr/bin/grep swatch | grep
       -v $$ | /usr/bin/awk '{print $1}'`
       echo $PID1 | tr -cs "[:digit:]" "[\n*]" | sort > /tmp/kill-swatch
   TAIL=`sort /tmp/kill-swatch | tail -1`
   PID2=`/usr/bin/ps -ef |/usr/bin/grep $TAIL | grep -v
       grep | /usr/bin/awk '{print $2}'`
        echo $PID2 | tr -cs "[:digit:]" "[\n*]" >> /tmp/kill-swatch
   TAIL=`sort /tmp/kill-swatch | tail -1`
   PID3=`/usr/bin/ps -ef |/usr/bin/grep $TAIL | grep -v
        grep | /usr/bin/awk '{print $2}'`
        echo $PID3 | tr -cs "[:digit:]" "[\n*]" >> /tmp/kill-swatch
                sort -r /tmp/kill-swatch > /tmp/kill-swatch-sorted
                uniq /tmp/kill-swatch-sorted /tmp/kill-swatch-uniq
                for PID in `cat /tmp/kill-swatch-uniq`
                do
                        /usr/bin/kill -9 ${PID} 1>/dev/null 2>&1
                done
                rm /tmp/kill-swat*
                ;;
 *)

-----EOF----

Much thanks to everybody:
 Rahul Roy <uroy@eadev1.vanguard.com>
Jim Harmon <jharmon@telecnnct.com>
Richard Bajusz <richb@osg.saic.com>
Bill Walker <bill.walker@sfa.org.uk>
 Paul Markham <pmarkham@world.net>
Alessandro Forghieri <alf@orion.it>
 Ronald Loftin <reloftin@mailbox.syr.edu>
Jim Seavey <jwseavey@norseaconsulting.com>
Karl Vogel <vogelke@c17mis.region2.wpafb.af.mil>
Mark Bergman <bergman@phri.nyu.edu>

===Original question===>
We have a variety of Sun servers which monitor via Swatch, a Perl program,
which some of you may be familiar. Right now, I start it up manually
as a regular user. Now i am wondering if this could be started by an rc
file on boot, and then proceed as a detached process. The question is
thus, "what makes a daemon a daemon under solaris; and can it be done in
Perl?"
 
If anybody has done such a similar tweak, I would surely like to know

<----Gregory Coleman -- Library & Center for Knowledge Management -- UCSF---->



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:12:30 CDT