<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: False NTP, how to compare 2 time stamps? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/false-ntp-how-to-compare-2-time-stamps/m-p/3224218#M714435</link>
    <description>Get the epoch time using perl etc. and do some mathes to know the difference in seconds.&lt;BR /&gt;&lt;BR /&gt;Such as &lt;BR /&gt;perl -e 'print time(), "\n"'&lt;BR /&gt;This will print time in epoch&lt;BR /&gt;&lt;BR /&gt;then&lt;BR /&gt;echo "epoch_time_1-epoch_time_2"|bc&lt;BR /&gt;&lt;BR /&gt;Hope this helps.&lt;BR /&gt;&lt;BR /&gt;Anil&lt;BR /&gt;</description>
    <pubDate>Fri, 19 Mar 2004 15:19:59 GMT</pubDate>
    <dc:creator>RAC_1</dc:creator>
    <dc:date>2004-03-19T15:19:59Z</dc:date>
    <item>
      <title>False NTP, how to compare 2 time stamps?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/false-ntp-how-to-compare-2-time-stamps/m-p/3224215#M714432</link>
      <description>I need to figure out a script to determine how many seconds two time stamps are apart.   I am writing a script in HP-UX POSIX shell but am willing to try other languages if the task is better suited. &lt;BR /&gt;&lt;BR /&gt;Easy example ( 31 seconds difference ) &lt;BR /&gt;14:45:32&lt;BR /&gt;14:45:01 &lt;BR /&gt;   &lt;BR /&gt;Hard example:   ( 31 seconds differnce )&lt;BR /&gt;23:59:01&lt;BR /&gt;00:00:29  &lt;BR /&gt;&lt;BR /&gt;Any ideas or assistance would be appreciated.    Here's the short answer to "why."   My MPE/iX admins can't or won't install NTP on our HP3000 servers so I wrote and Expect script that telnets to MPE and retreives the system time. I can then compare that to the current system (Unix ) time.  I simply want to know if they are more than 1 minute apart, then I'll generate an HP Openview and/or email alert so we know to set the system time asap. &lt;BR /&gt;&lt;BR /&gt;Of course, points will be awarded. &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 19 Mar 2004 14:55:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/false-ntp-how-to-compare-2-time-stamps/m-p/3224215#M714432</guid>
      <dc:creator>John J Read</dc:creator>
      <dc:date>2004-03-19T14:55:49Z</dc:date>
    </item>
    <item>
      <title>Re: False NTP, how to compare 2 time stamps?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/false-ntp-how-to-compare-2-time-stamps/m-p/3224216#M714433</link>
      <description>forgive the typo.. I'm aware that the times are not 31 seconds apart but you get the idea.</description>
      <pubDate>Fri, 19 Mar 2004 14:58:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/false-ntp-how-to-compare-2-time-stamps/m-p/3224216#M714433</guid>
      <dc:creator>John J Read</dc:creator>
      <dc:date>2004-03-19T14:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: False NTP, how to compare 2 time stamps?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/false-ntp-how-to-compare-2-time-stamps/m-p/3224217#M714434</link>
      <description>Note: Your second example is wrong; shpould be 88 seconds.&lt;BR /&gt;&lt;BR /&gt;First if you have Perl on your MPE box then this is trivially simple:&lt;BR /&gt;&lt;BR /&gt;try&lt;BR /&gt;perl -e 'print scalar time'&lt;BR /&gt;&lt;BR /&gt;That will yield epoch seconds gives you values you can readily subtract -- regardless of timezones.&lt;BR /&gt;&lt;BR /&gt;Plan B: Pure shell but I assume you can parse HH:MM:SS into 3 distinct variables&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;seconds()&lt;BR /&gt;{&lt;BR /&gt;  typeset -i10 HR=${1}&lt;BR /&gt;  typeset -i10 MIN=${2}&lt;BR /&gt;  typeset -i10 SEC=${3}&lt;BR /&gt;  shift 3&lt;BR /&gt;  typeset -i10 TM=$(( (${HR} * 3600) + (${MIN} * 60) + ${SEC} ))&lt;BR /&gt;  echo "${TM}"&lt;BR /&gt;  return 0&lt;BR /&gt;} # seconds&lt;BR /&gt;&lt;BR /&gt;typeset -i10 DIFF=0&lt;BR /&gt;typeset -i10 T1=$(seconds 23 59 01)&lt;BR /&gt;typeset -i10 T2=$(seconds 00 00 29)&lt;BR /&gt;if [[ ${T1} -gt ${T2} ]]&lt;BR /&gt;  then&lt;BR /&gt;    DIFF=$(( (86400 - ${T1}) + ${T2} ))&lt;BR /&gt;  else&lt;BR /&gt;    DIFF=$(( ${T2} - ${T1} ))&lt;BR /&gt;  fi&lt;BR /&gt;echo "Diff = ${DIFF} seconds."&lt;BR /&gt;&lt;BR /&gt;If I ain't made no typo's that should do it but it only allows for 1 day's wraparound and does assume that both times are same timezone. &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 19 Mar 2004 15:16:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/false-ntp-how-to-compare-2-time-stamps/m-p/3224217#M714434</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2004-03-19T15:16:31Z</dc:date>
    </item>
    <item>
      <title>Re: False NTP, how to compare 2 time stamps?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/false-ntp-how-to-compare-2-time-stamps/m-p/3224218#M714435</link>
      <description>Get the epoch time using perl etc. and do some mathes to know the difference in seconds.&lt;BR /&gt;&lt;BR /&gt;Such as &lt;BR /&gt;perl -e 'print time(), "\n"'&lt;BR /&gt;This will print time in epoch&lt;BR /&gt;&lt;BR /&gt;then&lt;BR /&gt;echo "epoch_time_1-epoch_time_2"|bc&lt;BR /&gt;&lt;BR /&gt;Hope this helps.&lt;BR /&gt;&lt;BR /&gt;Anil&lt;BR /&gt;</description>
      <pubDate>Fri, 19 Mar 2004 15:19:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/false-ntp-how-to-compare-2-time-stamps/m-p/3224218#M714435</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2004-03-19T15:19:59Z</dc:date>
    </item>
  </channel>
</rss>

