[KLUG Members] Help for a shell script to stop and start process

Adam Tauno Williams adam at morrison-ind.com
Mon Oct 10 11:23:36 EDT 2005


> A script is needed which comments the second line of
> the file and removes ones condition is fulfilled..

Do you actually want to CHANGE the contents of the file, as in "comment"
a line, or just execute the if statement's action clause?

> For example as mentioned down, I'm checking for the
> free memory, when it comes to some 50MB it should the
> comment the '#' at second line of the file

Do you realize this isn't how memory statistics work in UNIX?  You can
have 100k of memory available via free without having any kind of a
memory shortage or problem.  When UNIX allocates memory pages they are
never released until they are needed (it is a 'lazy' strategy).  so
"free" doesn't mean what it first seems.  Only paging activity indicates
a shortage of memory.

> /service/run and when the free memory comes to 200 it
> should remove '#' killing the process or perl.
> The script below is incomplete..
> #!/bin/bash
> echo RAM=`grep MemFree /proc/meminfo|tr -s
> [:blank:]|cut -f2 -d" "`
> echo SWAP=`grep SwapFree /proc/meminfo|tr -s
> [:blank:]|cut -f2 -d" "`
> echo PID=`pidof perl`
> if [ $RAM le= 563200 ]
> then wall "Free Memory is at 100"
> elif [ $RAM=530432 ]
> fi

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://www.kalamazoolinux.org/pipermail/members/attachments/20051010/b3ecc18b/attachment.bin


More information about the Members mailing list