Hi guys, I have to make an output of several databases we've got running on our system with the command bdf. This has to be done every 3 months. I want to put it in an scriptfile and trigger it in crontab. In the output it must display the differences in diskspace between these three monts. Any idea how to do this? I'm an newbie on hp-ux :o
To schedule script every 3 months in crontab:
0 0 3,6,9,12 * * script
Run bdf, write to a file
bdf [filesystem] | awk 'NR>1&&NF==5' > out_$(date +%b)
Later you can read from files for each month and compute difference.
Thx!
Is there a way to calculate the differences between this? I mean with a script.
Berkeley df can break the output in two lines,
even if the output is not connected to a terminal (e.g. to a pipe).
So it's safer to have
#!/bin/ksh -p
bdf | awk 'NR>1 && NF>=5 { print $(NF-1) }' > out_$(date +%b)
A post processor script (to be run in the directory with the 3 files) can look like this:
#!/bin/ksh -p
ls -rt |
while read file
do
read val < $file
val=${val%%%}
if [ -z "$preval" ]
then
preval=$val
else
delta=$(($val - $preval))
printf "%s: %d (%+d)\n" $file $val $delta
fi
done