<?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: Last working day of the month? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/last-working-day-of-the-month/m-p/3165807#M160261</link>
    <description>Well, since you already know about caljd.sh then this here ain't no hill for a climber. I would make certain that you have the latest version, 2.22 and that you /etc/acct/holidays files is current. I actually make a small "improvement" in the holidays file in that there should be an /etc/acct/holidays_YYYY that is symbolically linked to the current years /etc/acct/holidays because caljd.sh calculations might span years. The real key is to create a file that contains a line like&lt;BR /&gt;YYYY_MM:DD&lt;BR /&gt;for each month that the conditions are first satisfied. The DD is appended so that you can know what day actually triggered the command. The script itself simply searches for an entry YYYY_MM: at the beginning of a line. If that line is found then the stuff's done been did for this here month but if'fn you don't find no such entry then you ain't done did the command. In that case, do that there commmand and write me an entry in this here file.&lt;BR /&gt;&lt;BR /&gt;Something like this:&lt;BR /&gt;&lt;BR /&gt;------------------------------------&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;DTFILE="/var/spool/donedates"&lt;BR /&gt;&lt;BR /&gt;typeset -i10 STAT=0&lt;BR /&gt;if [[ $(caljd.sh -M) -ne $(caljd.sh -n 1 -x 6 -x 0 -h -M) ]]&lt;BR /&gt;  then # last working day of month&lt;BR /&gt;    typeset -i10 DO_IT=1&lt;BR /&gt;    typeset DT=$(date '+%Y_%m:')&lt;BR /&gt;    typeset DT_TARGET="^${DT}"&lt;BR /&gt;    if [[ -f "${DTFILE}" ]]&lt;BR /&gt;      then&lt;BR /&gt;        grep -q -E "${DT_TARGET}" ${DTFILE}&lt;BR /&gt;        FNDSTAT=${?}&lt;BR /&gt;        if [[ ${FNDSTAT} -eq 0 ]]&lt;BR /&gt;          then&lt;BR /&gt;            DO_IT=0&lt;BR /&gt;          fi&lt;BR /&gt;      fi&lt;BR /&gt;    if [[ ${DO_IT} -ne 0 ]]&lt;BR /&gt;      then # we have not already done it this month&lt;BR /&gt;        # Your commands go here and set STAT = 0&lt;BR /&gt;        # if ok &lt;BR /&gt;        #&lt;BR /&gt;        #  Now log the event to the date file so we only do this &lt;BR /&gt;        #  once per month&lt;BR /&gt;        if [[ ${STAT} -eq 0 ]]&lt;BR /&gt;          then&lt;BR /&gt;            echo "${DT}$(date '+%d')" &amp;gt;&amp;gt; ${DTFILE}&lt;BR /&gt;          fi&lt;BR /&gt;      fi&lt;BR /&gt;  fi&lt;BR /&gt;exit ${STAT}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;--------------------------------&lt;BR /&gt;I was typing this "on the fly" so I hope there are no typo's.&lt;BR /&gt;&lt;BR /&gt;That should do it, Clay&lt;BR /&gt;</description>
    <pubDate>Thu, 15 Jan 2004 16:17:07 GMT</pubDate>
    <dc:creator>A. Clay Stephenson</dc:creator>
    <dc:date>2004-01-15T16:17:07Z</dc:date>
    <item>
      <title>Last working day of the month?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/last-working-day-of-the-month/m-p/3165805#M160259</link>
      <description>Hello Gurus,&lt;BR /&gt;&lt;BR /&gt;I have searched the Forums and found a solution to the "last day of the month" using A. Clay's caljd.sh. I have not found a solution to determine the last working day of the month. For example, if the month ends on a Monday through Friday then it's very easy but if the month ends during the weekend or a holiday then I want the script to run before that. The other complication is that I want to run my scripts only once per month. For example, we typically are off from Christmas Eve until New Year's. I want the scripts to run only once for December.  &lt;BR /&gt;&lt;BR /&gt;I haven't been able to devise a method to do this. Any ideas out there?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;David Yandry</description>
      <pubDate>Thu, 15 Jan 2004 15:43:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/last-working-day-of-the-month/m-p/3165805#M160259</guid>
      <dc:creator>David Yandry</dc:creator>
      <dc:date>2004-01-15T15:43:44Z</dc:date>
    </item>
    <item>
      <title>Re: Last working day of the month?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/last-working-day-of-the-month/m-p/3165806#M160260</link>
      <description>With the exection of February -&lt;BR /&gt;`date +%u` | read day&lt;BR /&gt;`date +%d` | read day_of_month&lt;BR /&gt;&lt;BR /&gt;if [ $day -le 5 -a $day_of_month -ge 29 ]&lt;BR /&gt;then&lt;BR /&gt;    do whatever&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Still prefer Clay's amny examples.&lt;BR /&gt;&lt;BR /&gt;Best of luck.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;dl&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 15 Jan 2004 16:05:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/last-working-day-of-the-month/m-p/3165806#M160260</guid>
      <dc:creator>Dave La Mar</dc:creator>
      <dc:date>2004-01-15T16:05:45Z</dc:date>
    </item>
    <item>
      <title>Re: Last working day of the month?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/last-working-day-of-the-month/m-p/3165807#M160261</link>
      <description>Well, since you already know about caljd.sh then this here ain't no hill for a climber. I would make certain that you have the latest version, 2.22 and that you /etc/acct/holidays files is current. I actually make a small "improvement" in the holidays file in that there should be an /etc/acct/holidays_YYYY that is symbolically linked to the current years /etc/acct/holidays because caljd.sh calculations might span years. The real key is to create a file that contains a line like&lt;BR /&gt;YYYY_MM:DD&lt;BR /&gt;for each month that the conditions are first satisfied. The DD is appended so that you can know what day actually triggered the command. The script itself simply searches for an entry YYYY_MM: at the beginning of a line. If that line is found then the stuff's done been did for this here month but if'fn you don't find no such entry then you ain't done did the command. In that case, do that there commmand and write me an entry in this here file.&lt;BR /&gt;&lt;BR /&gt;Something like this:&lt;BR /&gt;&lt;BR /&gt;------------------------------------&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;DTFILE="/var/spool/donedates"&lt;BR /&gt;&lt;BR /&gt;typeset -i10 STAT=0&lt;BR /&gt;if [[ $(caljd.sh -M) -ne $(caljd.sh -n 1 -x 6 -x 0 -h -M) ]]&lt;BR /&gt;  then # last working day of month&lt;BR /&gt;    typeset -i10 DO_IT=1&lt;BR /&gt;    typeset DT=$(date '+%Y_%m:')&lt;BR /&gt;    typeset DT_TARGET="^${DT}"&lt;BR /&gt;    if [[ -f "${DTFILE}" ]]&lt;BR /&gt;      then&lt;BR /&gt;        grep -q -E "${DT_TARGET}" ${DTFILE}&lt;BR /&gt;        FNDSTAT=${?}&lt;BR /&gt;        if [[ ${FNDSTAT} -eq 0 ]]&lt;BR /&gt;          then&lt;BR /&gt;            DO_IT=0&lt;BR /&gt;          fi&lt;BR /&gt;      fi&lt;BR /&gt;    if [[ ${DO_IT} -ne 0 ]]&lt;BR /&gt;      then # we have not already done it this month&lt;BR /&gt;        # Your commands go here and set STAT = 0&lt;BR /&gt;        # if ok &lt;BR /&gt;        #&lt;BR /&gt;        #  Now log the event to the date file so we only do this &lt;BR /&gt;        #  once per month&lt;BR /&gt;        if [[ ${STAT} -eq 0 ]]&lt;BR /&gt;          then&lt;BR /&gt;            echo "${DT}$(date '+%d')" &amp;gt;&amp;gt; ${DTFILE}&lt;BR /&gt;          fi&lt;BR /&gt;      fi&lt;BR /&gt;  fi&lt;BR /&gt;exit ${STAT}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;--------------------------------&lt;BR /&gt;I was typing this "on the fly" so I hope there are no typo's.&lt;BR /&gt;&lt;BR /&gt;That should do it, Clay&lt;BR /&gt;</description>
      <pubDate>Thu, 15 Jan 2004 16:17:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/last-working-day-of-the-month/m-p/3165807#M160261</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2004-01-15T16:17:07Z</dc:date>
    </item>
    <item>
      <title>Re: Last working day of the month?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/last-working-day-of-the-month/m-p/3165808#M160262</link>
      <description>That was so ugly I'll post the script (thank God for Copy Buffers) as an attachment to make it prettier.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 15 Jan 2004 16:18:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/last-working-day-of-the-month/m-p/3165808#M160262</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2004-01-15T16:18:48Z</dc:date>
    </item>
    <item>
      <title>Re: Last working day of the month?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/last-working-day-of-the-month/m-p/3165809#M160263</link>
      <description>I should add that if you are running this from cron, make sure that you export and set PATH to include caljd.sh's location along with /usr/bin. I would execute the script once per day, Monday thru Fridays.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 15 Jan 2004 16:23:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/last-working-day-of-the-month/m-p/3165809#M160263</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2004-01-15T16:23:33Z</dc:date>
    </item>
    <item>
      <title>Re: Last working day of the month?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/last-working-day-of-the-month/m-p/3165810#M160264</link>
      <description>Thanks Clay. I have been working on this for 2 days and I'll bet that you did this in two minutes! and you made it look easy You're the man!!&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;David Yandry</description>
      <pubDate>Thu, 15 Jan 2004 16:38:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/last-working-day-of-the-month/m-p/3165810#M160264</guid>
      <dc:creator>David Yandry</dc:creator>
      <dc:date>2004-01-15T16:38:43Z</dc:date>
    </item>
  </channel>
</rss>

