Operating System - HP-UX
1833257 Members
3540 Online
110051 Solutions
New Discussion

Re: Glance and Date Changing

 
SOLVED
Go to solution
Mahesh Babbar
Frequent Advisor

Glance and Date Changing

Hi ,

I have a script as follows:
#!/bin/ksh
file=`date "+%d%m%Y"`
/opt/perf/bin/glance -j 60 -adviser_only -syntax /opt/perf/bin/advfile >> /var/glance_log/$file.log &

Purpose is to capture the data on per date basis.

Issue is that glance is not writing output to new file as the date changed rather it continues to write on the same file.

What's the best way to address this issue.

TIA

Mahesh

5 REPLIES 5
Laurent Menase
Honored Contributor
Solution

Re: Glance and Date Changing

Hi Mahesh
If you want to write more than one file you should do:
file=`date "+%d%m%Y"`
/opt/perf/bin/glance -j 60 -iterations $((24*60 - 1)) -adviser_only -syntax /opt/perf/bin/advfile >>/var/glance_log/$file.log &

starting it at 0:00:00 with cron

you can replace the $((24*60 -1)) by 1439
Borislav Perkov
Respected Contributor

Re: Glance and Date Changing

Hi,

The script starts only once and keep sending the output to $file at the moment glance starts. If you stop the execution of the script and start on different day it will send the output to new file. If your server reboots every day you can use -bootup option of glance, and everything will be find. If it is not a case you should find a way to restart your script, killing your glance process at midnight and starting it again.

Regards,
Borislav
Laurent Menase
Honored Contributor

Re: Glance and Date Changing

Or:
#!/bin/ksh

while :
do
file=`date "+%d%m%Y"`
/opt/perf/bin/glance -j 60 -adviser_only -syntax /opt/perf/bin/advfile >> /var/glance_log/$file.log &

echo $! > /var/tmp/glanceadv.pid
done

and in a cron

kill $(cat /var/tmp/glanceadv.pid )
Laurent Menase
Honored Contributor

Re: Glance and Date Changing

oops I forgot the wait else a lot of glance will be started

#!/bin/ksh

while :
do
file=`date "+%d%m%Y"`
/opt/perf/bin/glance -j 60 -adviser_only -syntax /opt/perf/bin/advfile >> /var/glance_log/$file.log &

echo $! > /var/tmp/glanceadv.pid

wait
done
Mahesh Babbar
Frequent Advisor

Re: Glance and Date Changing

Thanks to all for replying.

I will be using a combination of the solutions provided.

regards

Mahesh