<?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: How to get 5th Saturday? in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/how-to-get-5th-saturday/m-p/3997699#M96037</link>
    <description>seems like a lot of trouble  - the following snippet will return the 5th saturday of the current month, or a blank if there is none:&lt;BR /&gt;&lt;BR /&gt;cal | awk 'NR==7{print $7}'&lt;BR /&gt;&lt;BR /&gt;you could run this on the first of each month and based on the output, generate the alert.  for example:&lt;BR /&gt;&lt;BR /&gt;sat5=$( cal | awk 'NR==7{print $7}' )&lt;BR /&gt;if [[ -n $sat5 ]]; then&lt;BR /&gt;  : alert logic here&lt;BR /&gt;fi</description>
    <pubDate>Fri, 11 May 2007 09:30:53 GMT</pubDate>
    <dc:creator>Greg Vaidman</dc:creator>
    <dc:date>2007-05-11T09:30:53Z</dc:date>
    <item>
      <title>How to get 5th Saturday?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-get-5th-saturday/m-p/3997689#M96027</link>
      <description>Hello experts,&lt;BR /&gt;&lt;BR /&gt;We are allowed scheduled maintenance times 4 times each year on the 5th Saturday of a month. Is there a way to find the 5th Saturdays throughout the year so that we can automatically notify our users?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Ryan&lt;BR /&gt;</description>
      <pubDate>Thu, 10 May 2007 12:20:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-get-5th-saturday/m-p/3997689#M96027</guid>
      <dc:creator>Ryan Clerk</dc:creator>
      <dc:date>2007-05-10T12:20:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to get 5th Saturday?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-get-5th-saturday/m-p/3997690#M96028</link>
      <description>I am not sure if there is a system internal command for this but a snippet of code like this will give you the month calendars&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;year=2007&lt;BR /&gt;for i in 01 02 03 04 05 06 07 08 09 10 11 12&lt;BR /&gt;do&lt;BR /&gt;cal ${i} ${year} | grep -v [A-Z,a-z] grep [0-9]&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;will give you the monthly calendars.&lt;BR /&gt;store them in separate files and look for ones with 5 or 6 lines. In these files, 5th saturday is the last (7th field of) line number 5.&lt;BR /&gt;&lt;BR /&gt;Sorry I can not write the code for you as I have some buisness to tend right now, but this should get you going I hope.</description>
      <pubDate>Thu, 10 May 2007 12:39:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-get-5th-saturday/m-p/3997690#M96028</guid>
      <dc:creator>Mel Burslan</dc:creator>
      <dc:date>2007-05-10T12:39:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to get 5th Saturday?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-get-5th-saturday/m-p/3997691#M96029</link>
      <description>sorry I forgot a pipe between two grep commands on the line starting with "cal" command. Please beware</description>
      <pubDate>Thu, 10 May 2007 12:39:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-get-5th-saturday/m-p/3997691#M96029</guid>
      <dc:creator>Mel Burslan</dc:creator>
      <dc:date>2007-05-10T12:39:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to get 5th Saturday?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-get-5th-saturday/m-p/3997692#M96030</link>
      <description>Shalom,&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.hpux.ws/caljd.sh" target="_blank"&gt;http://www.hpux.ws/caljd.sh&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://www.hpux.ws/caljd.pl" target="_blank"&gt;http://www.hpux.ws/caljd.pl&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;SEP&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 10 May 2007 12:43:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-get-5th-saturday/m-p/3997692#M96030</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2007-05-10T12:43:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to get 5th Saturday?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-get-5th-saturday/m-p/3997693#M96031</link>
      <description>&lt;!--!*#--&gt;Hi Ryan,&lt;BR /&gt;&lt;BR /&gt;Set environmental variable Y to the year of interest (e.g. Y=$(date +%Y)), and then:&lt;BR /&gt;&lt;BR /&gt;for M in 01 02 03 04 05 06 07 08 09 10 11 12&lt;BR /&gt;do&lt;BR /&gt;  cal ${M} ${Y} | awk -v M=${M}-v Y=${Y} 'NR==7 {if($7 !~ /^$/){printf("%s/%s/%s\n",M,$7,Y)}}'&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;PCS&lt;BR /&gt;</description>
      <pubDate>Thu, 10 May 2007 13:30:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-get-5th-saturday/m-p/3997693#M96031</guid>
      <dc:creator>spex</dc:creator>
      <dc:date>2007-05-10T13:30:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to get 5th Saturday?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-get-5th-saturday/m-p/3997694#M96032</link>
      <description>Well, I wouldn't write no code for the special case of the 5th Saturday but some years back I did write some code for the general case. (I think the PC guys needed the 2nd Sunday for something or other and on account of it being Windows I wrote it in Perl.)&lt;BR /&gt;&lt;BR /&gt;This should work.&lt;BR /&gt;&lt;BR /&gt;dayofmonth.pl -w 6 -n 5 &lt;BR /&gt;without a year argument the current year is assummed.&lt;BR /&gt;dayofmonth.pl -w 6 -n 5 2012&lt;BR /&gt;will work for 2012.&lt;BR /&gt;&lt;BR /&gt;Invoke as dayofmonth.pl -u for full usage.</description>
      <pubDate>Thu, 10 May 2007 14:15:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-get-5th-saturday/m-p/3997694#M96032</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-05-10T14:15:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to get 5th Saturday?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-get-5th-saturday/m-p/3997695#M96033</link>
      <description>You will also need the Perl script, caljd.pl, called by the previous script.&lt;BR /&gt;</description>
      <pubDate>Thu, 10 May 2007 14:16:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-get-5th-saturday/m-p/3997695#M96033</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-05-10T14:16:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to get 5th Saturday?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-get-5th-saturday/m-p/3997696#M96034</link>
      <description>I hadn't touched dayofmonth.pl in over 3 years and because caljd.pl has added the optional abbreviated and full month names which include NLS support during this time, I added the feature to dayofmonth.pl as well. This is dayofmonth.pl Vrsn 1.02p.&lt;BR /&gt;</description>
      <pubDate>Thu, 10 May 2007 16:39:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-get-5th-saturday/m-p/3997696#M96034</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-05-10T16:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to get 5th Saturday?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-get-5th-saturday/m-p/3997697#M96035</link>
      <description>How about using cron to a generic messaging script?&lt;BR /&gt;&lt;BR /&gt;18 * * * 6 [`date "+%d"` -gt 28] &amp;amp;&amp;amp; /path/to/script</description>
      <pubDate>Fri, 11 May 2007 07:48:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-get-5th-saturday/m-p/3997697#M96035</guid>
      <dc:creator>Craig Sterley</dc:creator>
      <dc:date>2007-05-11T07:48:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to get 5th Saturday?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-get-5th-saturday/m-p/3997698#M96036</link>
      <description>How about a simple brute-force:&lt;BR /&gt;&lt;BR /&gt;--- special-saturdays.pl ---&lt;BR /&gt;use strict;&lt;BR /&gt;my $try = time();&lt;BR /&gt;my $DAY = 86400; # 24 * 60 *60&lt;BR /&gt;for (0..365) {&lt;BR /&gt; $try += $DAY;&lt;BR /&gt; my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($try);&lt;BR /&gt; print scalar localtime($try)."\n" if ($wday == 6 and $mday &amp;gt; 28);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;#perl special-saturdays.pl &lt;BR /&gt;Sat Jun 30 06:53:49 2007&lt;BR /&gt;Sat Sep 29 06:53:49 2007&lt;BR /&gt;Sat Dec 29 05:53:49 2007&lt;BR /&gt;Sat Mar 29 05:53:49 2008&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Similar building your own date format...&lt;BR /&gt;&lt;BR /&gt;use strict;&lt;BR /&gt;my $try = time();&lt;BR /&gt;my $DAY = 86400; # 24 * 60 *60&lt;BR /&gt;for (0..365) {&lt;BR /&gt; $try += $DAY;&lt;BR /&gt; my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($try);&lt;BR /&gt; printf "%d-%02d-%02d\n",$year+1900,$mon+1,$mday if ($wday == 6 and $mday &amp;gt; 28);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;perl  special-saturdays.pl&lt;BR /&gt;2007-06-30&lt;BR /&gt;2007-09-29&lt;BR /&gt;2007-12-29&lt;BR /&gt;2008-03-29&lt;BR /&gt;&lt;BR /&gt;fwiw,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Fri, 11 May 2007 08:59:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-get-5th-saturday/m-p/3997698#M96036</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-05-11T08:59:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to get 5th Saturday?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-get-5th-saturday/m-p/3997699#M96037</link>
      <description>seems like a lot of trouble  - the following snippet will return the 5th saturday of the current month, or a blank if there is none:&lt;BR /&gt;&lt;BR /&gt;cal | awk 'NR==7{print $7}'&lt;BR /&gt;&lt;BR /&gt;you could run this on the first of each month and based on the output, generate the alert.  for example:&lt;BR /&gt;&lt;BR /&gt;sat5=$( cal | awk 'NR==7{print $7}' )&lt;BR /&gt;if [[ -n $sat5 ]]; then&lt;BR /&gt;  : alert logic here&lt;BR /&gt;fi</description>
      <pubDate>Fri, 11 May 2007 09:30:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-get-5th-saturday/m-p/3997699#M96037</guid>
      <dc:creator>Greg Vaidman</dc:creator>
      <dc:date>2007-05-11T09:30:53Z</dc:date>
    </item>
  </channel>
</rss>

