Hi, I am not really good at shell scripting. I usually cut and paste from other scripts and customize it to do what I need. I am running Oracle 10g on AIX 5.3 machine and I need a script that monitors a filesystem, I would say at least every hour by cron, and if the filesystem hits above 80% full then I want the script to start deleting the oldest files in the filesystem first until the filesystem is back down to 50% full.
I have scripts that monitor the filesystem, but the whole 80 to 50% thing is where I am stumped. I have this script which I use to check the FS size and then email me when it gets past a certain percentage, was hoping I could modify that one maybe:
#!/bin/sh
. /proddb/u01/app/oracle/dbtools/dba_email_list.sh
#echo $DBA_EMAIL
S=/proddb/u01/app/oracle/dbtools/
cat /dev/null > $S/filesystem%
df -k | egrep '/oraaudit' | awk '$4 ~ /^96%/ || $4 ~ /^97%/ || $4 ~ /^98%/ || $4 ~ /^99%/ || $4 ~ /^100%/' > $S/filesystem%
egrep -s "/" $S/filesystem%
case $? in
0)
mail -s "Account Cust - file system above threshold on `hostname`" dbaemail@whatever.com < $S/filesystem%;;
*)
;;
esac
. Anyone able to assist me? I would really appreciate it. Thanks.
Jim
My guess would be that the part where I need to do the rm -rf to start deleting would go right where the mail part is.