<div dir="ltr"><div class="gmail_default" style="color:rgb(51,51,255);font-family:verdana,sans-serif">Yup! it was exactly due to the switch at the end of 23 hours 59 minutes.</div><div class="gmail_default" style="color:rgb(51,51,255);font-family:verdana,sans-serif">
I had to change my code to :</div><div class="gmail_default" style="color:rgb(51,51,255);font-family:verdana,sans-serif"> </div><div class="gmail_default" style="color:rgb(51,51,255);font-family:verdana,sans-serif">uptime | awk '{print $(NF-2)" " $(NF-1)" " $NF }'</div>
<div class="gmail_default" style="color:rgb(51,51,255);font-family:verdana,sans-serif"> </div><div class="gmail_default" style="color:rgb(51,51,255);font-family:verdana,sans-serif">that way I always have the last 3 columns, irrespective of the day.</div>
<div class="gmail_default" style="color:rgb(51,51,255);font-family:verdana,sans-serif"> </div><div class="gmail_default" style="color:rgb(51,51,255);font-family:verdana,sans-serif">After I saw that hour switch every 24 hours, I felt so ashamed of missing that.</div>
<div class="gmail_default" style="color:rgb(51,51,255);font-family:verdana,sans-serif"> </div><div class="gmail_default" style="color:rgb(51,51,255);font-family:verdana,sans-serif">Thanks once again for the help.</div><div class="gmail_default" style="color:rgb(51,51,255);font-family:verdana,sans-serif">
</div><div class="gmail_default" style="color:rgb(51,51,255);font-family:verdana,sans-serif">-GG</div></div><div class="gmail_extra"><br clear="all"><div><div dir="ltr"><div><span style="color:rgb(51,51,255);font-family:verdana,sans-serif"></span> </div>
<div><span style="color:rgb(51,51,255);font-family:verdana,sans-serif">-GG</span></div></div></div>
<br><br><div class="gmail_quote">On Wed, Jun 5, 2013 at 5:31 AM, John Szakmeister <span dir="ltr"><<a href="mailto:john@szakmeister.net" target="_blank">john@szakmeister.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Tue, Jun 4, 2013 at 8:09 AM, Rajiv Gunja <<a href="mailto:opn.src.rocks@gmail.com">opn.src.rocks@gmail.com</a>> wrote:<br>
> This is not on Linux, but on Solaris/Unix.<br>
><br>
> I have a few servers on which I am running a few commands via cron.<br>
> Examples commands: date, uptime, sar, netstat, dladm, prstat, ping.<br>
><br>
> Here is the command sequence I am having the issue:<br>
><br>
> ldavg=`uptime | cut -d":" -f4`<br>
><br>
> DDATE1=`date +'%Y.%d.%h.%H.%M.%S'`<br>
><br>
> echo "$DDATE1 >>> $ldavg" >> /var/adm/save/2ping/load.avg.log 2>&1<br>
><br>
> In the log file, on some servers, once every hour, it will miss output of<br>
> the variable $ldavg. So the entried will look like this :<br>
<br>
</div>That is strange. I initially thought maybe you were hitting a time<br>
where perhaps the time didn't have the extra colon for the seconds if<br>
you hit right on the minute boundary when executing uptime.<br>
<div class="im"><br>
> 2013.04.Jun.07.23.24 >>> 1.12, 1.23, 1.25<br>
><br>
> 2013.04.Jun.07.24.29 >>> 1.03, 1.18, 1.23<br>
><br>
> 2013.04.Jun.07.25.35 >>> 1.10, 1.18, 1.22<br>
><br>
> 2013.04.Jun.07.26.40 >>> 1.45, 1.30, 1.26<br>
><br>
> 2013.04.Jun.07.27.45 >>><br>
<br>
</div>I don't think this can be due to missing the output (I hope that<br>
couldn't happen!). Rather, since the line is there at all, I think<br>
it's more like the input string changed in a slightly unexpected way,<br>
so you're asking for a field that doesn't exist, which will come back<br>
empty.<br>
<div class="im"><br>
><br>
> 2013.04.Jun.07.28.50 >>> 1.10, 1.23, 1.24<br>
><br>
> 2013.04.Jun.07.29.55 >>> 1.08, 1.20, 1.23<br>
><br>
> 2013.04.Jun.07.31.01 >>> 1.66, 1.29, 1.26<br>
><br>
> 2013.04.Jun.07.32.06 >>> 1.27, 1.25, 1.25<br>
><br>
><br>
> I have no explanation as to why this would miss and that too at exactly that<br>
> time every hour. My script runs these commands once a minute, every hour.<br>
<br>
</div>Perhaps a different tactic will work with the varying number of colons:<br>
<br>
uptime | sed -e "s/^.*: //"<br>
<br>
Just eat everything until the last colon and space, and what's left<br>
will be your averages.<br>
<span class="HOEnZb"><font color="#888888"><br>
-John<br>
</font></span></blockquote></div><br></div>