Mailing Lists: Apple Mailing Lists

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

Re: Uptime question (Unix-related)




On Feb 14, 2007, at 14:18, Nick McSpadden wrote:

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

I get a different location for uptime, so I modified the LAVG line. BTW, if your load average goes up over 0.99, you'd not see the whole number.



#!/bin/bash LAVG=`uptime | cut -c 48-49` LAVG=`uptime` LAVG=`expr "$LAVG" : '.*\: [^\.]*\.\(..\)'` THRESHOLD=40 if [ "$LAVG" -gt $THRESHOLD ] then # <do great things> echo do else # <do lesser things> echo do not fi

John


------------------------------------------------------------------------ --
"They that can give up essential liberty to obtain a little
temporary safety deserve neither liberty nor safety."
---- Benjamin Franklin
--------------- "Dotage," Beneteau 373 -----------------
John P. Mundt Network Manager
Hawthorn District 73 email@hidden
Vernon Hills, IL 60061 847-990-4591




_______________________________________________
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>)
 >Uptime question (Unix-related) (From: Nick McSpadden <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.