<?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 Help with writing a cron script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-writing-a-cron-script/m-p/3310071#M711892</link>
    <description>All,&lt;BR /&gt;&lt;BR /&gt;I need to write an Inifinite Loop in Korn Sheel. This script is supposed to kick off every day at around 12:00 PM. &lt;BR /&gt;&lt;BR /&gt;I wrote the script like this:&lt;BR /&gt;###################################################################&lt;BR /&gt;&lt;BR /&gt;  export FILE_DIR=$TOP/bin&lt;BR /&gt;&lt;BR /&gt;  if [ $# = 0 ]; then&lt;BR /&gt;    interval=86400&lt;BR /&gt;  elif [ "${1}" = "fast" ]; then&lt;BR /&gt;    interval=900&lt;BR /&gt;  else echo "Incorrect usage........."&lt;BR /&gt;    echo "Execute without parmeter or with parameter 'fast' to execute in fast mode"&lt;BR /&gt;    exit 1&lt;BR /&gt;  fi&lt;BR /&gt;&lt;BR /&gt;      t=1000&lt;BR /&gt;&lt;BR /&gt;      while [ ${t} -le 1001 ];&lt;BR /&gt;      do&lt;BR /&gt;       switch_val=`head -1 auto_on_off.txt | awk '{print $1}'`&lt;BR /&gt;&lt;BR /&gt;     if [ "${switch_val}" = "on" ]; then&lt;BR /&gt;       ${FILE_DIR}/run_load_A_B.ksh db1 db2 db3&lt;BR /&gt;       ${FILE_DIR}/run_load_C.ksh db1 db2 db3&lt;BR /&gt;         #sleep 86400&lt;BR /&gt;          sleep ${interval}&lt;BR /&gt;         echo "condition not yet fulfilled run again after 24 hrs"&lt;BR /&gt;       else&lt;BR /&gt;         a=1&lt;BR /&gt;       #exit 1&lt;BR /&gt;       fi&lt;BR /&gt;       done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;My Problem is that the scripts:&lt;BR /&gt;&lt;BR /&gt;run_load_A_B.ksh&lt;BR /&gt;run_load_C.ksh&lt;BR /&gt;take 4-5 hours to run .&lt;BR /&gt;&lt;BR /&gt;once they complete the script sleeps for 24 hours. and next dat it executes at the finish time of previois day.&lt;BR /&gt;How do I make sure it runs at a specific time each day provided previous day's run was completed.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The script runs in 2 modes normal and fast mode. I am concerned abt the normal mode ( every 24 hours )&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Please suggest any good logic for this.&lt;BR /&gt;&lt;BR /&gt;Thank You,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Sun, 20 Jun 2004 17:48:34 GMT</pubDate>
    <dc:creator>Suman_7</dc:creator>
    <dc:date>2004-06-20T17:48:34Z</dc:date>
    <item>
      <title>Help with writing a cron script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-writing-a-cron-script/m-p/3310071#M711892</link>
      <description>All,&lt;BR /&gt;&lt;BR /&gt;I need to write an Inifinite Loop in Korn Sheel. This script is supposed to kick off every day at around 12:00 PM. &lt;BR /&gt;&lt;BR /&gt;I wrote the script like this:&lt;BR /&gt;###################################################################&lt;BR /&gt;&lt;BR /&gt;  export FILE_DIR=$TOP/bin&lt;BR /&gt;&lt;BR /&gt;  if [ $# = 0 ]; then&lt;BR /&gt;    interval=86400&lt;BR /&gt;  elif [ "${1}" = "fast" ]; then&lt;BR /&gt;    interval=900&lt;BR /&gt;  else echo "Incorrect usage........."&lt;BR /&gt;    echo "Execute without parmeter or with parameter 'fast' to execute in fast mode"&lt;BR /&gt;    exit 1&lt;BR /&gt;  fi&lt;BR /&gt;&lt;BR /&gt;      t=1000&lt;BR /&gt;&lt;BR /&gt;      while [ ${t} -le 1001 ];&lt;BR /&gt;      do&lt;BR /&gt;       switch_val=`head -1 auto_on_off.txt | awk '{print $1}'`&lt;BR /&gt;&lt;BR /&gt;     if [ "${switch_val}" = "on" ]; then&lt;BR /&gt;       ${FILE_DIR}/run_load_A_B.ksh db1 db2 db3&lt;BR /&gt;       ${FILE_DIR}/run_load_C.ksh db1 db2 db3&lt;BR /&gt;         #sleep 86400&lt;BR /&gt;          sleep ${interval}&lt;BR /&gt;         echo "condition not yet fulfilled run again after 24 hrs"&lt;BR /&gt;       else&lt;BR /&gt;         a=1&lt;BR /&gt;       #exit 1&lt;BR /&gt;       fi&lt;BR /&gt;       done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;My Problem is that the scripts:&lt;BR /&gt;&lt;BR /&gt;run_load_A_B.ksh&lt;BR /&gt;run_load_C.ksh&lt;BR /&gt;take 4-5 hours to run .&lt;BR /&gt;&lt;BR /&gt;once they complete the script sleeps for 24 hours. and next dat it executes at the finish time of previois day.&lt;BR /&gt;How do I make sure it runs at a specific time each day provided previous day's run was completed.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The script runs in 2 modes normal and fast mode. I am concerned abt the normal mode ( every 24 hours )&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Please suggest any good logic for this.&lt;BR /&gt;&lt;BR /&gt;Thank You,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sun, 20 Jun 2004 17:48:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-writing-a-cron-script/m-p/3310071#M711892</guid>
      <dc:creator>Suman_7</dc:creator>
      <dc:date>2004-06-20T17:48:34Z</dc:date>
    </item>
    <item>
      <title>Re: Help with writing a cron script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-writing-a-cron-script/m-p/3310072#M711893</link>
      <description>the easiest way is just to let cron run the job everyday at 12.&lt;BR /&gt;&lt;BR /&gt;0 12 * * * command&lt;BR /&gt;</description>
      <pubDate>Sun, 20 Jun 2004 18:53:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-writing-a-cron-script/m-p/3310072#M711893</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2004-06-20T18:53:43Z</dc:date>
    </item>
    <item>
      <title>Re: Help with writing a cron script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-writing-a-cron-script/m-p/3310073#M711894</link>
      <description>and if you like computing the wait time yourself&lt;BR /&gt;&lt;BR /&gt;You can download caljd.sh or caljd.pl from here:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.cmve.net/~merijn/#Contrib" target="_blank"&gt;http://www.cmve.net/~merijn/#Contrib&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;It is at the bottom of the page. &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;YESTERDAY_DATE=$(caljd.sh -s -y $(caljd.sh -p 1))&lt;BR /&gt;echo "Yesterday = ${YESTERDAY_DATE}"&lt;BR /&gt;TOMORROW_DATE=$(caljd.sh -s -y $(caljd.sh -n 1))&lt;BR /&gt;echo "Tomorrow = ${TOMORROW_DATE}"&lt;BR /&gt;&lt;BR /&gt;Invoke as caljd.sh -u for full usage and many examples (like previous date plus skip over weekends).  &lt;BR /&gt;</description>
      <pubDate>Sun, 20 Jun 2004 18:55:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-writing-a-cron-script/m-p/3310073#M711894</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2004-06-20T18:55:52Z</dc:date>
    </item>
    <item>
      <title>Re: Help with writing a cron script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-writing-a-cron-script/m-p/3310074#M711895</link>
      <description>y don't you let it run in the back ground ?.&lt;BR /&gt;&lt;BR /&gt;command1 &amp;amp;&lt;BR /&gt;command2 &amp;amp;&lt;BR /&gt;sleep &lt;TIME&gt;&lt;BR /&gt;&lt;BR /&gt;Kaps&lt;/TIME&gt;</description>
      <pubDate>Sun, 20 Jun 2004 19:01:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-writing-a-cron-script/m-p/3310074#M711895</guid>
      <dc:creator>KapilRaj</dc:creator>
      <dc:date>2004-06-20T19:01:48Z</dc:date>
    </item>
    <item>
      <title>Re: Help with writing a cron script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-writing-a-cron-script/m-p/3310075#M711896</link>
      <description>Thanks for the reply , but I can't use cron job as this is the requirement. &lt;BR /&gt;&lt;BR /&gt;I can't let it run in the background because the users want the ability to turn it on and off as desitred by updating the auto_on_off.txt file to "on" or "off"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;</description>
      <pubDate>Sun, 20 Jun 2004 19:05:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-writing-a-cron-script/m-p/3310075#M711896</guid>
      <dc:creator>Suman_7</dc:creator>
      <dc:date>2004-06-20T19:05:00Z</dc:date>
    </item>
    <item>
      <title>Re: Help with writing a cron script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-writing-a-cron-script/m-p/3310076#M711897</link>
      <description>You've already got the logic in there for the auto_on_off, so if they say 'off', it won't run.&lt;BR /&gt;&lt;BR /&gt;Now, the executing of the script 1000 times can also be gotten rid of.&lt;BR /&gt;&lt;BR /&gt;Simply, you could shorten the entire routine to something like this:&lt;BR /&gt;&lt;BR /&gt;###########&lt;BR /&gt;# Start here&lt;BR /&gt;&lt;BR /&gt;export FILE_DIR=$TOP/bin&lt;BR /&gt;LOCK_FILE=$0.lock&lt;BR /&gt;&lt;BR /&gt;if [ ! -f "$LOCK_FILE" ]&lt;BR /&gt;then&lt;BR /&gt;&lt;BR /&gt;touch "$LOCK_FILE"&lt;BR /&gt;switch_val=`head -1 auto_on_off.txt | awk '{print $1}'`&lt;BR /&gt;&lt;BR /&gt;if [ "${switch_val}" = "on" ]; then&lt;BR /&gt;${FILE_DIR}/run_load_A_B.ksh db1 db2 db3&lt;BR /&gt;${FILE_DIR}/run_load_C.ksh db1 db2 db3&lt;BR /&gt;&lt;BR /&gt;##&lt;BR /&gt;# Insert logic here checking for failures.  If failed, don't do the next line:&lt;BR /&gt;&lt;BR /&gt;if [ ..&lt;PASSED&gt;.. ]&lt;BR /&gt;then&lt;BR /&gt;rm -f "$LOCK_FILE"&lt;BR /&gt;fi&lt;BR /&gt;else&lt;BR /&gt;echo "Lock file still in place.  Either a previous execution failed, or I was run multiple times."&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;######################&lt;BR /&gt;&lt;BR /&gt;And cron it!&lt;/PASSED&gt;</description>
      <pubDate>Sun, 20 Jun 2004 19:15:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-writing-a-cron-script/m-p/3310076#M711897</guid>
      <dc:creator>Stuart Browne</dc:creator>
      <dc:date>2004-06-20T19:15:37Z</dc:date>
    </item>
    <item>
      <title>Re: Help with writing a cron script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-writing-a-cron-script/m-p/3310077#M711898</link>
      <description>Your requirement is having some contraversies as,&lt;BR /&gt;&lt;BR /&gt; You are in need to start the script execution at 12.00 PM Everyday.But the application execution time (3-4hours) + the sleep time 24 hours (86400 seconds or 900 seconds) may leed to execute the execution on next day after 12.00 PM limit.&lt;BR /&gt;&lt;BR /&gt; You have to use different logic for fast mode. It is good to use the log files to know the execution time and other informations.&lt;BR /&gt;&lt;BR /&gt; Attached script will be helpful for this.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Muthukumar</description>
      <pubDate>Mon, 21 Jun 2004 04:08:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-writing-a-cron-script/m-p/3310077#M711898</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2004-06-21T04:08:20Z</dc:date>
    </item>
    <item>
      <title>Re: Help with writing a cron script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-writing-a-cron-script/m-p/3310078#M711899</link>
      <description>Try this:&lt;BR /&gt;&lt;BR /&gt;elapsed=0&lt;BR /&gt;while :&lt;BR /&gt;do&lt;BR /&gt;   head -1 auto_on_off.txt | read switch_val therest&lt;BR /&gt;&lt;BR /&gt;   &lt;BR /&gt;   if [[ "${switch_val}" = "on" ]]&lt;BR /&gt;   then&lt;BR /&gt;      ${FILE_DIR}/run_load_A_B.ksh db1 db2 db3&lt;BR /&gt;      ${FILE_DIR}/run_load_C.ksh db1 db2 db3&lt;BR /&gt;&lt;BR /&gt;      sleep $((interval - elapsed))&lt;BR /&gt;      elapsed=0&lt;BR /&gt;      echo "condition not yet fulfilled run again after 24 hrs"&lt;BR /&gt;else&lt;BR /&gt;   a=1&lt;BR /&gt;   sleep 60&lt;BR /&gt;   ((elapsed += 60))&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;</description>
      <pubDate>Thu, 24 Jun 2004 12:28:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-writing-a-cron-script/m-p/3310078#M711899</guid>
      <dc:creator>Dan Martin_1</dc:creator>
      <dc:date>2004-06-24T12:28:56Z</dc:date>
    </item>
  </channel>
</rss>

