The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM
Home Forums Register Rules & FAQ Members List Arcade Search Today's Posts Mark Forums Read


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. Shell Script Page.


Other UNIX.COM Threads You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Need suggestions about a datecheck script tsmurray Shell Programming and Scripting 5 05-14-2008 08:23 AM
syntex error script any suggestions kim187 Shell Programming and Scripting 5 04-29-2008 10:56 PM
suggestions require for unix system performance on certain task zing_foru UNIX for Advanced & Expert Users 4 04-26-2007 07:12 AM
AIX server performance problem! ctcuser UNIX for Advanced & Expert Users 3 12-02-2004 08:44 PM
performance problem caoai UNIX for Advanced & Expert Users 5 03-06-2002 04:36 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-22-2008
Registered User
 

Join Date: Jun 2006
Location: Los Angeles
Posts: 17
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
Question Performance problem with my script ...suggestions pls

Hi ,
I have included my script below, pls read thro this req. I want my script to run for every hour , the problem is I CANNOT USE CRONTAB which is prohibited inside the company. My script does what it is supposed to do (to determine the memory and then send a email if it crosses a certain limit) . So I put a while loop which is always true so that the script can run forever using nohup but the problem is that this script if run using nohup and while true condition seem to REALLY take up almost 1 full cpu from the server (our server is a 3 cpu box) ..do u guys have any idea how to make this less CPU intensive one..??
_____ Script ----
#!/bin/ksh
set -A proc $x
x=$(top| grep sieb |awk '{print $6}'|sed 's/\M//')
print $x
HOME=/users/home/con
TEMPDIR=$HOME
FILE=mail.log
set -A proc $x
print "Number of sieb process currently running is ${#proc[@]}"
#assigning the total number of processes to a var
procnum=${#proc[@]}
print ${proc[1]}
#to make the script run contineous im putting a while [true]
while [ true ]
do
#intializing a counter var to be in loop
i=0
while [ $i -lt $procnum ]
do
echo 'Start checking '
if [ ${proc[i]} -gt 1420 ]
then
echo Process Sieb seem to occupy more memory about ${proc[i]} MB so will sleep for 10mins before i do next check
sleep 600
typically 62% means the overall emory is 83%
cp=$(prstat -t 1 1 | awk '/sad/{print $5;}'|sed 's/\%//')
echo $cp is the % MEM
if [ ${proc[i]} -gt 1420 ] && [ $cp -gt 61 ]
then
echo Sieb seem to occupy more memory so will send a email
/usr/bin/mailx -s "ALERT: process memory on rog is high " "con@yahoo.com" < $TEMPDIR/$FILE
sleep 3600
fi
fi
print ${#proc[$i]}
((i=i+1))
echo $i
done
done

Last edited by vivsiv : 02-22-2008 at 01:06 PM. Reason: corrections
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 02-22-2008
awk awk is offline
Registered User
 

Join Date: Feb 2007
Posts: 109
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
quick answer - use the "sleep" command to make your process go dormant for a set amount of time.

do a man sleep - but basically, the command is sleep <seconds>
Reply With Quote
  #3 (permalink)  
Old 02-22-2008
kpearson's Avatar
Registered User
 

Join Date: Nov 2006
Location: Lehi, Utah, USA
Posts: 15
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
My first thought was using sleep, too, but he is.

Code:
sleep 600
So, maybe that long of a sleep is giving the CPU fits? when I had this problem before, and wasn't using a sleep command, I solved it using sleep 1 which gave the CPU plenty of time to catch up on other things.

I can't imagine a company setting a policy against using one of the most powerful friends a sysadmin has. Amazing what people do.... But, I've an open mind. Convince me that prohibiting the use of cron is a good idea.
Reply With Quote
Google UNIX.COM
Reply



Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 11:13 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger

Search Engine Optimization by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102