Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Uptime question (Unix-related)



This is really more of a UNIX question than an ARD question, so sorry if this is off topic.

I want to set up a repeated job on the macs that checks their load average and then performs certain tasks based on that.  It's easy enough to do load average checking with the UNIX command "uptime."

I know I can get the load average amount with the UNIX command:
uptime | cut -c 48-49
(so if the load average is 0.18, I'll get 18 as the number).  

I then want to test this against a threshold amount, such as 40 (i.e. if load average goes above 0.4):

In a UNIX shell script, i can set this to:


#!/bin/bash
let LAVG=`uptime | cut -c 48-49`
let THRESHOLD=40
if ( $LAVG > $THRESHOLD)
then 
<do stuff....>
else
<do something else....>
fi

Problem is, I can't get the conditional to work right.   I know UNIX variables don't care about their content (they aren't typecasted like in C/C++), but it seems the comparison is failing.  What can I do to make sure it goes through?

I know the value in $LAVG is being treated arithmetically, because I can perform arithmetic problems on it (i.e. if $LAVG=50, $LAVG-40 gives me 10, as expected).

Any clues?
--
Nick McSpadden
Schools of the Sacred Heart
Technology Network Assistant


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Remote-desktop mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/remote-desktop/email@hidden

This email sent to email@hidden

References: 
 >Killing Applications using ARD (From: Theresa Bright <email@hidden>)
 >Re: Killing Applications using ARD (From: "Robert Jacobson" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.