<?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: setup the crontab job in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/setup-the-crontab-job/m-p/3937018#M288280</link>
    <description>Oops, I'm an idiot. I forgot to attach the caljd.sh script. Here it is. Invoke as caljd.sh -u for full usage and many examples as it makes otherwise difficult date calculations trivially simple.&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Fri, 02 Feb 2007 00:02:14 GMT</pubDate>
    <dc:creator>A. Clay Stephenson</dc:creator>
    <dc:date>2007-02-02T00:02:14Z</dc:date>
    <item>
      <title>setup the crontab job</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/setup-the-crontab-job/m-p/3937015#M288277</link>
      <description>If I would like to set a crontab schedule job that run one time only per month , the day must the first Sunday of every month , I try " 0 1 1 * 0" , but it will run every Sundy and 1st , can advise what can I set ? thx</description>
      <pubDate>Thu, 01 Feb 2007 22:48:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/setup-the-crontab-job/m-p/3937015#M288277</guid>
      <dc:creator>hangyu</dc:creator>
      <dc:date>2007-02-01T22:48:40Z</dc:date>
    </item>
    <item>
      <title>Re: setup the crontab job</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/setup-the-crontab-job/m-p/3937016#M288278</link>
      <description>Cron by itself cannot do this and although you thought that by specifying both a weekday and a monthday, you were specfying a logical AND as you have discovered it is a logical OR. What you can do is have cron run the job every Sunday and then let the job itself determine if this is the 1st Sunday or if not simply exit. Use the attached script, caljd.sh, to determine if it is the 1st occurence of a given weekday in the month. I would install it in /usr/local/bin.&lt;BR /&gt;&lt;BR /&gt;Your cron'ed script should look something like this:&lt;BR /&gt;--------------------------------&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;export PATH=${PATH}:/usr/local/bin&lt;BR /&gt;&lt;BR /&gt;if [[ $(caljd.sh -N) -eq 1 ]]&lt;BR /&gt;then&lt;BR /&gt;  echo "It's the first Sunday; do your thing"&lt;BR /&gt;else&lt;BR /&gt;  # it's not&lt;BR /&gt;  exit 0&lt;BR /&gt;fi</description>
      <pubDate>Thu, 01 Feb 2007 23:25:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/setup-the-crontab-job/m-p/3937016#M288278</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-02-01T23:25:48Z</dc:date>
    </item>
    <item>
      <title>Re: setup the crontab job</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/setup-the-crontab-job/m-p/3937017#M288279</link>
      <description>Can't be done with cron. Each item in the list (min hr day month wkday) is checked and a match for any setting will trigger the job. TTo accomplish what you want, you need to write your cron script to see if the current day of the month is 1-7, and if not true, exit. Then add the job to cron to run every Sunday. The script will choose the first week of the month.</description>
      <pubDate>Thu, 01 Feb 2007 23:30:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/setup-the-crontab-job/m-p/3937017#M288279</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2007-02-01T23:30:00Z</dc:date>
    </item>
    <item>
      <title>Re: setup the crontab job</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/setup-the-crontab-job/m-p/3937018#M288280</link>
      <description>Oops, I'm an idiot. I forgot to attach the caljd.sh script. Here it is. Invoke as caljd.sh -u for full usage and many examples as it makes otherwise difficult date calculations trivially simple.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 02 Feb 2007 00:02:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/setup-the-crontab-job/m-p/3937018#M288280</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-02-02T00:02:14Z</dc:date>
    </item>
    <item>
      <title>Re: setup the crontab job</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/setup-the-crontab-job/m-p/3937019#M288281</link>
      <description>&lt;!--!*#--&gt;If you want to just check for Sunday, instead of using Clay's script, you can do:&lt;BR /&gt;   DAY=$(date +%a)&lt;BR /&gt;&lt;BR /&gt;If you are worked about locales, you can use:&lt;BR /&gt;   DAYOFWEEK=$(date +%u)&lt;BR /&gt;&lt;BR /&gt;Where Sunday is 7.&lt;BR /&gt;if [ $DAYOFWEEK -eq 7 ]; then  # Sunday</description>
      <pubDate>Fri, 02 Feb 2007 00:17:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/setup-the-crontab-job/m-p/3937019#M288281</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-02-02T00:17:35Z</dc:date>
    </item>
  </channel>
</rss>

