Linux
– Shell Scripting
Automatically
Moving Archive to Backup Location
#!/bin/ksh
printf "\n Automatically move Archivelogs to other
mountpoint once getting full ---
\n"
retcode=$?
filesize=`df -k |grep /u02 | awk '{ print
$5 }'`
mname=`df -k | grep /u02 | awk '{ print $6
}'`
mpct=${filesize//%}
if
[ $retcode != '0' ]; then
printf "FATAL ERROR \n"
ERROR_FLG='1'
else
if [ $mpct -gt 50 ]; then
printf "\n Alert -
Mountpoint - $mname is above 50 and
$mpct pct - utilizezd ...\n"
printf "\n Message : Start
Clearing Mount point ....... \n"
printf "\n Running
........... \n"
mv /u02/Archive/*.arc /Backup/
printf "\n Finished
........... \n"
newsize=`df -k |grep /u02 | awk '{ print $5 }'`
nsize=${newsize//%}
printf "\n Current Utilization $mname is $nsize\n"
else
printf "\n Filesystem is
stable and available is $mpct \n"
fi
fi
Create
an entry in cron tab with periodically check every hour.
No comments:
Post a Comment