![]() |
|
|
|||||||
| 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 |
![]() |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
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 |
| Forum Sponsor | ||
|
|