![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Please help - disk space check script | maddhadder71 | Shell Programming and Scripting | 0 | 05-08-2008 09:16 AM |
| Check the Disk usage Programmatically | SriSri | High Level Programming | 2 | 09-20-2005 04:15 AM |
| Script to check for a file, check for 2hrs. then quit | mmarsh | UNIX for Dummies Questions & Answers | 2 | 09-16-2005 03:46 PM |
| Hard Disk Check | muneebr | UNIX for Dummies Questions & Answers | 5 | 08-30-2005 05:37 PM |
| check disk | chris_carmo | UNIX for Advanced & Expert Users | 1 | 05-10-2004 10:28 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
I wrote a script that checks particular device path directory which is full or more than 90% used, and will search older file inside and delete it. My code looks like this: Code:
#!/usr/bin/ksh
ref=90
df -k | grep /cbmdata/00/gdd | tr -d '%' | \
while read a b c d e other
do
if (( $e >= $ref )) && continue
then
line=`find /cbmdata/00/gdd -name "LOGS*" |sort -nr |tail -1`
# echo $line
rm -f $line
fi
done
it works but not good, sometimes it only deletes only one file whereas I want it check the disk size and if more than 90 % in use go and delete another old file..it uses cronjob to timing... Could you please advise me how can I make my script more robust or porfessional ? Thanks
|
|
||||
|
Try this (untested ):Code:
#!/usr/bin/ksh
ref=90
while [ 1 ]
do
df -k | grep /cbmdata/00/gdd | tr -d '%' | \
read a b c d e other
if (( "$e" >= "$ref" ))
then
line=`find /cbmdata/00/gdd -name "LOGS*" |sort -nr |tail -1`
# echo $line
rm -f $line
else
exit 0
fi
done
Regards |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|