<?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: Cron / Scheduling Problem in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-scheduling-problem/m-p/2621205#M843232</link>
    <description>Wow! Richard, I have to agree with you. This is just perfect! Clay, even my "$GO_WK" was zero. How did you know?&lt;BR /&gt;&lt;BR /&gt;Darrell yours was good too but Clay's was perfect. I've been looking at his caljd.sh script and I can't begin to understand how it works but it does.  &lt;BR /&gt;&lt;BR /&gt;Thanks again, Greg</description>
    <pubDate>Wed, 28 Nov 2001 00:53:19 GMT</pubDate>
    <dc:creator>Greg White</dc:creator>
    <dc:date>2001-11-28T00:53:19Z</dc:date>
    <item>
      <title>Cron / Scheduling Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-scheduling-problem/m-p/2621201#M843228</link>
      <description>Hello everyone:&lt;BR /&gt;&lt;BR /&gt;I need to schedule a cron job to run every fourth Friday at 11:00 PM. I can make the the cron job run every Friday but when I try to use the week number in the date command, it  doesn't always work when I go from one year to the next. Is there an easy answer for this? &lt;BR /&gt;&lt;BR /&gt;Thanks in advance, Greg&lt;BR /&gt;</description>
      <pubDate>Wed, 28 Nov 2001 00:00:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-scheduling-problem/m-p/2621201#M843228</guid>
      <dc:creator>Greg White</dc:creator>
      <dc:date>2001-11-28T00:00:49Z</dc:date>
    </item>
    <item>
      <title>Re: Cron / Scheduling Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-scheduling-problem/m-p/2621202#M843229</link>
      <description>Hi Greg:&lt;BR /&gt;&lt;BR /&gt;I have a deal for you. What you are going to do is turn todays date into a Julian Day. (~ the number of days since 4713 BCE). Astronomers use this method to make orbital calculations easy. I'll attach my caljd.sh to do all the hard work. I assume you already have the cron entry to fire off the command every Friday at 2300. We now just need to determine if this is the correct Friday and execute some command or simply exit. Try this:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;GO_WK=0&lt;BR /&gt;# GO_WK should be in the range 0-3 depending&lt;BR /&gt;# on which week you wish to start this &lt;BR /&gt;export PATH=${PATH}:/usr/local/bin&lt;BR /&gt;STAT=0&lt;BR /&gt;WK=$(( (($(caljd.sh) + 1) / 7) % 4))&lt;BR /&gt;if [ ${GO_WK} -eq ${WK} ]&lt;BR /&gt;  then&lt;BR /&gt;    echo "Execute Command" # should set STAT&lt;BR /&gt;  fi&lt;BR /&gt;exit ${STAT}&lt;BR /&gt;  &lt;BR /&gt;---------------------------&lt;BR /&gt;&lt;BR /&gt;You should install caljd.sh in /usr/local/bin (or some other convenient place but set the PATH accordingly).&lt;BR /&gt;&lt;BR /&gt;Now here's what it is doing.&lt;BR /&gt;We get the current Julian Day and add 1 to it. (that simply makes the weeks start on Sunday).&lt;BR /&gt;Next we integer divide by 7 to get the number of the week since 4713BCE. We then do a mod 4 to get a number in the range of 0 to 3 - just what you need. &lt;BR /&gt;&lt;BR /&gt;You can execute cajld.sh -u for full usage.&lt;BR /&gt;&lt;BR /&gt;Enjoy, Clay&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 28 Nov 2001 00:15:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-scheduling-problem/m-p/2621202#M843229</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2001-11-28T00:15:24Z</dc:date>
    </item>
    <item>
      <title>Re: Cron / Scheduling Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-scheduling-problem/m-p/2621203#M843230</link>
      <description>I gotta hand to you Mr. Clay but you are a HELL OF A SCRIPT WRITTER!!!!&lt;BR /&gt;&lt;BR /&gt;Richard</description>
      <pubDate>Wed, 28 Nov 2001 00:28:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-scheduling-problem/m-p/2621203#M843230</guid>
      <dc:creator>someone_4</dc:creator>
      <dc:date>2001-11-28T00:28:35Z</dc:date>
    </item>
    <item>
      <title>Re: Cron / Scheduling Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-scheduling-problem/m-p/2621204#M843231</link>
      <description>Hi Greg,&lt;BR /&gt;&lt;BR /&gt;Cron, in and of itself, isn't smart enough to do what you want.  My approach would be to schedule a cron job at 23:00 every Friday.  That job would run a script that verifies the day_of_month is 22 - 28.  If so, run your job else edit.&lt;BR /&gt;&lt;BR /&gt;That works because the 4th Friday (or any other day of the week) is always the 22nd - 28th.&lt;BR /&gt;&lt;BR /&gt;Just saw Clay's solution which is much more elegant.  I'm going to have to check it out to see how I can begin using it.&lt;BR /&gt;&lt;BR /&gt;Anyway, you could use my method.&lt;BR /&gt;&lt;BR /&gt;Darrell</description>
      <pubDate>Wed, 28 Nov 2001 00:33:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-scheduling-problem/m-p/2621204#M843231</guid>
      <dc:creator>Darrell Allen</dc:creator>
      <dc:date>2001-11-28T00:33:56Z</dc:date>
    </item>
    <item>
      <title>Re: Cron / Scheduling Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-scheduling-problem/m-p/2621205#M843232</link>
      <description>Wow! Richard, I have to agree with you. This is just perfect! Clay, even my "$GO_WK" was zero. How did you know?&lt;BR /&gt;&lt;BR /&gt;Darrell yours was good too but Clay's was perfect. I've been looking at his caljd.sh script and I can't begin to understand how it works but it does.  &lt;BR /&gt;&lt;BR /&gt;Thanks again, Greg</description>
      <pubDate>Wed, 28 Nov 2001 00:53:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-scheduling-problem/m-p/2621205#M843232</guid>
      <dc:creator>Greg White</dc:creator>
      <dc:date>2001-11-28T00:53:19Z</dc:date>
    </item>
    <item>
      <title>Re: Cron / Scheduling Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-scheduling-problem/m-p/2621206#M843233</link>
      <description>This problem can be resolved using cron itself as well, the line in your crontab file would be:&lt;BR /&gt;&lt;BR /&gt;00 10 22-28 * 5 &lt;COMMAND to="" execute=""&gt;&lt;BR /&gt;&lt;BR /&gt;This would perform the desired function on the fourth friday of every month at 10:00.&lt;BR /&gt;&lt;BR /&gt;&lt;/COMMAND&gt;</description>
      <pubDate>Wed, 03 Apr 2002 15:06:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-scheduling-problem/m-p/2621206#M843233</guid>
      <dc:creator>William Fishburne</dc:creator>
      <dc:date>2002-04-03T15:06:36Z</dc:date>
    </item>
    <item>
      <title>Re: Cron / Scheduling Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-scheduling-problem/m-p/2621207#M843234</link>
      <description>Hi William:&lt;BR /&gt;&lt;BR /&gt;You may be correct but I interpreted Greg's question to be every 4th Friday (i.e. 28 days) rather than the 4th Friday of a given month. This was hinted at by his attempt to use the week number in the date command but only Greg knows for sure.&lt;BR /&gt;</description>
      <pubDate>Wed, 03 Apr 2002 15:53:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-scheduling-problem/m-p/2621207#M843234</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-04-03T15:53:23Z</dc:date>
    </item>
    <item>
      <title>Re: Cron / Scheduling Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-scheduling-problem/m-p/2621208#M843235</link>
      <description>Hello William:&lt;BR /&gt;&lt;BR /&gt;Thanks for the response but Clay interpreted my question correctly. I apologize for being unclear. In our case, we have bi-weekly payroll runs and some special processing is done  after  every other payroll run rather than the fourth Friday of each month.&lt;BR /&gt;&lt;BR /&gt;Greg&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 03 Apr 2002 20:28:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-scheduling-problem/m-p/2621208#M843235</guid>
      <dc:creator>Greg White</dc:creator>
      <dc:date>2002-04-03T20:28:17Z</dc:date>
    </item>
  </channel>
</rss>

