<?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: Checking for a certain time and date variable within a script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/checking-for-a-certain-time-and-date-variable-within-a-script/m-p/2550317#M27980</link>
    <description>Actually Tim, this is a stand alone process not ran through cron.  We kick it off by&lt;BR /&gt;nohup ./sqlcapture &amp;gt; nohup.out &amp;amp;&lt;BR /&gt;&lt;BR /&gt;Any then this guy just keeps running unless we make changes to the code.  Then it is stoped and then restarted.  There is much more to this script, but only the CRITICAL status is what he wants to be paged on.  Do you think that because it is a continues running process, that this is why it is not working correctly?  I'm grasping for straws now.</description>
    <pubDate>Mon, 09 Jul 2001 17:46:51 GMT</pubDate>
    <dc:creator>Mark Cook</dc:creator>
    <dc:date>2001-07-09T17:46:51Z</dc:date>
    <item>
      <title>Checking for a certain time and date variable within a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/checking-for-a-certain-time-and-date-variable-within-a-script/m-p/2550307#M27970</link>
      <description>I have a script that checks sql durations and wanted to have the system page me within the hours of 8:00am and 17:00pm Monday through Friday only.  Below is a portion of the code.  If I take out the time/day checks and test it with simple echo statements, it appears to work.  This is ran in the ksh shell.  Any suggestions/help would be GREAT!&lt;BR /&gt;Thanks - Mark&lt;BR /&gt;&lt;BR /&gt;TIME=`date +%H`&lt;BR /&gt;DAY=`date +%a`&lt;BR /&gt;&lt;BR /&gt;if [ "${diff_t}" -ge "${CRITICAL_T}" -a "${diff_t}" -le `expr "${CRITICAL_T}" + "${RUN_F}"` -o $IS_FIRST &lt;BR /&gt;-eq 0 ]&lt;BR /&gt;        then &lt;BR /&gt;echo "---&amp;gt; Info for session $session `date +%c`" &amp;gt;&amp;gt;$CRITICAL_FILE&lt;BR /&gt;&lt;BR /&gt;#Check for day and time&lt;BR /&gt;        if [[ $TIME -gt 08 &amp;amp;&amp;amp; $TIME -lt 17 &amp;amp;&amp;amp; $DAY != Sat &amp;amp;&amp;amp; $DAY != Sun ]];&lt;BR /&gt;        then&lt;BR /&gt;                echo "Info for session $session, \"CRITICAL\"" |mail mark_page &lt;BR /&gt;        else&lt;BR /&gt;                :&lt;BR /&gt;        fi&lt;BR /&gt;                onstat -g ses $session &amp;gt;&amp;gt; $CRITICAL_FILE&lt;BR /&gt;                onstat -u |grep " $session " &amp;gt;&amp;gt; $CRITICAL_FILE&lt;BR /&gt;                onstat -g ntt |grep " $session " &amp;gt;&amp;gt; $CRITICAL_FILE&lt;BR /&gt;                onstat -g ses |grep "$session " |read a1 b1 c1 d1 f1 g1 h1&lt;BR /&gt;                if [ "$d1" -gt 0 ]; then&lt;BR /&gt;                        ps -fea | grep " $d1 " &amp;gt;&amp;gt;$CRITICAL_FILE&lt;BR /&gt;                fi&lt;BR /&gt;                echo "---&amp;gt; END\n\n" &amp;gt;&amp;gt;$CRITICAL_FILE&lt;BR /&gt;        fi&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 09 Jul 2001 15:33:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/checking-for-a-certain-time-and-date-variable-within-a-script/m-p/2550307#M27970</guid>
      <dc:creator>Mark Cook</dc:creator>
      <dc:date>2001-07-09T15:33:53Z</dc:date>
    </item>
    <item>
      <title>Re: Checking for a certain time and date variable within a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/checking-for-a-certain-time-and-date-variable-within-a-script/m-p/2550308#M27971</link>
      <description>Can you post the whole script?&lt;BR /&gt;I would like to use it if it does work.&lt;BR /&gt;&lt;BR /&gt;thanks&lt;BR /&gt;&lt;BR /&gt;Richard</description>
      <pubDate>Mon, 09 Jul 2001 15:53:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/checking-for-a-certain-time-and-date-variable-within-a-script/m-p/2550308#M27971</guid>
      <dc:creator>someone_4</dc:creator>
      <dc:date>2001-07-09T15:53:23Z</dc:date>
    </item>
    <item>
      <title>Re: Checking for a certain time and date variable within a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/checking-for-a-certain-time-and-date-variable-within-a-script/m-p/2550309#M27972</link>
      <description>Hi Mark,&lt;BR /&gt;I have one script in perl does good job.&lt;BR /&gt;&lt;BR /&gt; if ($Curr_Date &amp;gt; 15 &amp;amp;&amp;amp; $Date &amp;lt; 5){&lt;BR /&gt;          chomp;&lt;BR /&gt;          $User{$uname}++;&lt;BR /&gt;          print FILE "$_       more then 10 Days old\n";&lt;BR /&gt;          next;&lt;BR /&gt;    }&lt;BR /&gt;    if ($Curr_Date &amp;gt; 20 &amp;amp;&amp;amp; $Date &amp;lt; 10){&lt;BR /&gt;          chomp;&lt;BR /&gt;          $User{$uname}++;&lt;BR /&gt;          print FILE "$_       more then 10 Days old\n";&lt;BR /&gt;          next;&lt;BR /&gt;    }&lt;BR /&gt;</description>
      <pubDate>Mon, 09 Jul 2001 16:24:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/checking-for-a-certain-time-and-date-variable-within-a-script/m-p/2550309#M27972</guid>
      <dc:creator>Sachin Patel</dc:creator>
      <dc:date>2001-07-09T16:24:55Z</dc:date>
    </item>
    <item>
      <title>Re: Checking for a certain time and date variable within a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/checking-for-a-certain-time-and-date-variable-within-a-script/m-p/2550310#M27973</link>
      <description>Mark,&lt;BR /&gt;&lt;BR /&gt;I'm wondering if the statement:&lt;BR /&gt;&lt;BR /&gt;if [[ $TIME -gt 08 &lt;BR /&gt;&lt;BR /&gt;is hosing up because of the 08, rather than just reporting 8.  This may be ugly, but can you check for each hour between 8 and 17? That is:&lt;BR /&gt;&lt;BR /&gt;if [[ $TIME=08 || $TIME=09 || $TIME=10 ... $TIME=17 &amp;amp;&amp;amp; $DAY != Sat &amp;amp;&amp;amp; $DAY != Sun ]] (notice the || OR instead of &amp;amp;&amp;amp; AND) and see if that works?  I'm wondering if KSH is seeing 08 as a string and not a number, so that the -gt is throwing it off..&lt;BR /&gt;&lt;BR /&gt;My $.02...&lt;BR /&gt;&lt;BR /&gt;-Tim&lt;BR /&gt;</description>
      <pubDate>Mon, 09 Jul 2001 16:46:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/checking-for-a-certain-time-and-date-variable-within-a-script/m-p/2550310#M27973</guid>
      <dc:creator>Timothy Czarnik</dc:creator>
      <dc:date>2001-07-09T16:46:51Z</dc:date>
    </item>
    <item>
      <title>Re: Checking for a certain time and date variable within a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/checking-for-a-certain-time-and-date-variable-within-a-script/m-p/2550311#M27974</link>
      <description>Thanks to everyone for their suggestions...Tim I understand what you are saying, but if I simply write a script like:&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;&lt;BR /&gt;TIME=`date +%H`&lt;BR /&gt;DAY=`date +%a`&lt;BR /&gt;&lt;BR /&gt;if [[ $TIME -gt 08 &amp;amp;&amp;amp; $TIME -lt 17 &amp;amp;&amp;amp; $DAY != Sat &amp;amp;&amp;amp; $DAY != Sun ]];&lt;BR /&gt;then&lt;BR /&gt;           echo "Hello"&lt;BR /&gt;else&lt;BR /&gt;           :&lt;BR /&gt;fi&lt;BR /&gt;####&lt;BR /&gt;It works just fine...that is why I'm confused.&lt;BR /&gt;</description>
      <pubDate>Mon, 09 Jul 2001 16:54:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/checking-for-a-certain-time-and-date-variable-within-a-script/m-p/2550311#M27974</guid>
      <dc:creator>Mark Cook</dc:creator>
      <dc:date>2001-07-09T16:54:33Z</dc:date>
    </item>
    <item>
      <title>Re: Checking for a certain time and date variable within a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/checking-for-a-certain-time-and-date-variable-within-a-script/m-p/2550312#M27975</link>
      <description>Mark,&lt;BR /&gt;&lt;BR /&gt;With -gt 08 and -lt 17, this would only run between 9:00 am and 4:59 pm.  That is, the hours 8 and 17 are not inclusive.  That is what you are shooting for?&lt;BR /&gt;&lt;BR /&gt;-Tim&lt;BR /&gt;</description>
      <pubDate>Mon, 09 Jul 2001 17:01:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/checking-for-a-certain-time-and-date-variable-within-a-script/m-p/2550312#M27975</guid>
      <dc:creator>Timothy Czarnik</dc:creator>
      <dc:date>2001-07-09T17:01:47Z</dc:date>
    </item>
    <item>
      <title>Re: Checking for a certain time and date variable within a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/checking-for-a-certain-time-and-date-variable-within-a-script/m-p/2550313#M27976</link>
      <description>Tim,&lt;BR /&gt;Good point, actually it should be -gt 07:59 and -lt 17:01.  I guess that would actually get everything from 8 to 5.  That still does not explain to me why our DBA was getting paged at 22:00 over the weekend.  Thoughts...?</description>
      <pubDate>Mon, 09 Jul 2001 17:05:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/checking-for-a-certain-time-and-date-variable-within-a-script/m-p/2550313#M27976</guid>
      <dc:creator>Mark Cook</dc:creator>
      <dc:date>2001-07-09T17:05:37Z</dc:date>
    </item>
    <item>
      <title>Re: Checking for a certain time and date variable within a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/checking-for-a-certain-time-and-date-variable-within-a-script/m-p/2550314#M27977</link>
      <description>Mark,&lt;BR /&gt;&lt;BR /&gt;Actually, the date +%H is only going to give the hour as a 2 digit number.  It would never be 07:59 or something like that.  You would probably want &lt;BR /&gt;&lt;BR /&gt;if [[ $TIME -gt 7 &amp;amp;&amp;amp; $TIME -lt 18....&lt;BR /&gt;&lt;BR /&gt;better yet,&lt;BR /&gt;&lt;BR /&gt;if [[ $TIME -ge 8 &amp;amp;&amp;amp; $TIME -lt 17 (this covers 8:00 AM - 4:59 PM)&lt;BR /&gt;&lt;BR /&gt;Why would it page at 22:00 on a Weekend night?  Still looking and thinking, but from what I can see, it couldn't... is this the only instance of this script running?&lt;BR /&gt;&lt;BR /&gt;-Tim&lt;BR /&gt;</description>
      <pubDate>Mon, 09 Jul 2001 17:14:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/checking-for-a-certain-time-and-date-variable-within-a-script/m-p/2550314#M27977</guid>
      <dc:creator>Timothy Czarnik</dc:creator>
      <dc:date>2001-07-09T17:14:21Z</dc:date>
    </item>
    <item>
      <title>Re: Checking for a certain time and date variable within a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/checking-for-a-certain-time-and-date-variable-within-a-script/m-p/2550315#M27978</link>
      <description>Tim,&lt;BR /&gt;Yep that makes much sense.  When you ask "is this the only instance of this script running" what do you actually mean by that.  I'm sorry to have to ask that.  By the way, if it is easier for you, you can e-mail me at&lt;BR /&gt;cookm@fleishman.com&lt;BR /&gt;I really want to thank you for your efforts.&lt;BR /&gt;Mark</description>
      <pubDate>Mon, 09 Jul 2001 17:18:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/checking-for-a-certain-time-and-date-variable-within-a-script/m-p/2550315#M27978</guid>
      <dc:creator>Mark Cook</dc:creator>
      <dc:date>2001-07-09T17:18:17Z</dc:date>
    </item>
    <item>
      <title>Re: Checking for a certain time and date variable within a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/checking-for-a-certain-time-and-date-variable-within-a-script/m-p/2550316#M27979</link>
      <description>Mark,&lt;BR /&gt;&lt;BR /&gt;I'm wondering if there isn't another cron entry on this or another server that calls this same script (or one like it) that has the hour/day check mixed up, or a -gt where a -lt is needed...&lt;BR /&gt;&lt;BR /&gt;From what I see, there is no way this action would be performed unless it is between 8 AM and 5 PM on a weekday.&lt;BR /&gt;&lt;BR /&gt;Also, in the 'else' section of the if loop, does it perform a similar action?  I'm not sure if you removed the else section to save space/typing, or if that is the way it actually exists in the script.  If there is nothing in the 'else' section, you can just remove it.&lt;BR /&gt;&lt;BR /&gt;-Tim&lt;BR /&gt;</description>
      <pubDate>Mon, 09 Jul 2001 17:30:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/checking-for-a-certain-time-and-date-variable-within-a-script/m-p/2550316#M27979</guid>
      <dc:creator>Timothy Czarnik</dc:creator>
      <dc:date>2001-07-09T17:30:57Z</dc:date>
    </item>
    <item>
      <title>Re: Checking for a certain time and date variable within a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/checking-for-a-certain-time-and-date-variable-within-a-script/m-p/2550317#M27980</link>
      <description>Actually Tim, this is a stand alone process not ran through cron.  We kick it off by&lt;BR /&gt;nohup ./sqlcapture &amp;gt; nohup.out &amp;amp;&lt;BR /&gt;&lt;BR /&gt;Any then this guy just keeps running unless we make changes to the code.  Then it is stoped and then restarted.  There is much more to this script, but only the CRITICAL status is what he wants to be paged on.  Do you think that because it is a continues running process, that this is why it is not working correctly?  I'm grasping for straws now.</description>
      <pubDate>Mon, 09 Jul 2001 17:46:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/checking-for-a-certain-time-and-date-variable-within-a-script/m-p/2550317#M27980</guid>
      <dc:creator>Mark Cook</dc:creator>
      <dc:date>2001-07-09T17:46:51Z</dc:date>
    </item>
    <item>
      <title>Re: Checking for a certain time and date variable within a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/checking-for-a-certain-time-and-date-variable-within-a-script/m-p/2550318#M27981</link>
      <description>Mark,&lt;BR /&gt;&lt;BR /&gt;I sent you an email to the address you listed above.&lt;BR /&gt;&lt;BR /&gt;Is this a newly generated script, or has it been running for some time without incident?&lt;BR /&gt;&lt;BR /&gt;-Tim&lt;BR /&gt;</description>
      <pubDate>Mon, 09 Jul 2001 18:09:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/checking-for-a-certain-time-and-date-variable-within-a-script/m-p/2550318#M27981</guid>
      <dc:creator>Timothy Czarnik</dc:creator>
      <dc:date>2001-07-09T18:09:27Z</dc:date>
    </item>
    <item>
      <title>Re: Checking for a certain time and date variable within a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/checking-for-a-certain-time-and-date-variable-within-a-script/m-p/2550319#M27982</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;I don't know if it helps you any, but here is a bit of script I was just playing with after reading this thread.  There is an argument for the 'date' command that will return the day of the week as a number (1-Mon, 2-Tue...7-Sun), so it allows you to check for the day of the week as a number instead of a string.  I use this in a script that ejects a DDS tape daily each Monday through Friday morning after a backup, but leaves the tape alone on the weekend.  Here is the script I was playing with:&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh                                                     &lt;BR /&gt;                                                              &lt;BR /&gt;# date_test                                                   &lt;BR /&gt;                                                              &lt;BR /&gt;while true                                                    &lt;BR /&gt;do                                                            &lt;BR /&gt;    TIME=$(date +'%H')                                        &lt;BR /&gt;    DAY=$(date +'%u')                                         &lt;BR /&gt;                                                              &lt;BR /&gt;    if [[ $TIME -gt 7 &amp;amp;&amp;amp; $TIME -lt 17 &amp;amp;&amp;amp; $DAY -lt 6 ]]        &lt;BR /&gt;    then                                                      &lt;BR /&gt;        print "TIME to work: HOUR is $TIME and WKDAY is $DAY" &lt;BR /&gt;    else                                                      &lt;BR /&gt;        print "TIME to go home"                               &lt;BR /&gt;    fi                                                        &lt;BR /&gt;    sleep 60                                                  &lt;BR /&gt;done                                                          &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;</description>
      <pubDate>Mon, 09 Jul 2001 20:12:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/checking-for-a-certain-time-and-date-variable-within-a-script/m-p/2550319#M27982</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2001-07-09T20:12:21Z</dc:date>
    </item>
  </channel>
</rss>

