<?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 in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/cron/m-p/3210643#M168451</link>
    <description>Sadly, cron's not sophisticated enough to handle this without help.&lt;BR /&gt;&lt;BR /&gt;You need to set the job to run on the saturday, then have logic within the script to test if the day is in the first seven days of the month&lt;BR /&gt;&lt;BR /&gt;eg:&lt;BR /&gt;&lt;BR /&gt;DATE_DAY=`date +%d`&lt;BR /&gt;&lt;BR /&gt;if [ $DATE_DAY -le 7 ]&lt;BR /&gt;then&lt;BR /&gt;......&lt;BR /&gt;......&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;This checks if the current day is less than or equal to 7, and runs the code in the if statement.</description>
    <pubDate>Fri, 05 Mar 2004 10:24:56 GMT</pubDate>
    <dc:creator>Chris Wilshaw</dc:creator>
    <dc:date>2004-03-05T10:24:56Z</dc:date>
    <item>
      <title>cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron/m-p/3210642#M168450</link>
      <description>Does anyone know how to make a cron job run&lt;BR /&gt;only on the first weekend of the month with&lt;BR /&gt;saturday and sunday being in that month, not&lt;BR /&gt;split. And starting on saturday. Don't think&lt;BR /&gt;it can be done with cron. &lt;BR /&gt;&lt;BR /&gt;The following crontab entry runs on the 1st&lt;BR /&gt;thru the 7th and "also" on saturday not "if"&lt;BR /&gt;it is saturday within the 1st - 7th day of the&lt;BR /&gt;month.&lt;BR /&gt;&lt;BR /&gt;0 0 1-7 * 6 &lt;COMMAND&gt;&lt;/COMMAND&gt;</description>
      <pubDate>Fri, 05 Mar 2004 10:03:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron/m-p/3210642#M168450</guid>
      <dc:creator>jerry1</dc:creator>
      <dc:date>2004-03-05T10:03:35Z</dc:date>
    </item>
    <item>
      <title>Re: cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron/m-p/3210643#M168451</link>
      <description>Sadly, cron's not sophisticated enough to handle this without help.&lt;BR /&gt;&lt;BR /&gt;You need to set the job to run on the saturday, then have logic within the script to test if the day is in the first seven days of the month&lt;BR /&gt;&lt;BR /&gt;eg:&lt;BR /&gt;&lt;BR /&gt;DATE_DAY=`date +%d`&lt;BR /&gt;&lt;BR /&gt;if [ $DATE_DAY -le 7 ]&lt;BR /&gt;then&lt;BR /&gt;......&lt;BR /&gt;......&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;This checks if the current day is less than or equal to 7, and runs the code in the if statement.</description>
      <pubDate>Fri, 05 Mar 2004 10:24:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron/m-p/3210643#M168451</guid>
      <dc:creator>Chris Wilshaw</dc:creator>
      <dc:date>2004-03-05T10:24:56Z</dc:date>
    </item>
    <item>
      <title>Re: cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron/m-p/3210644#M168452</link>
      <description>The only option I can think of is to have it run every Saturday and Sunday and then put some logic in the job to determine if it is the first weekend of the month or not. If it is, proceed with the rest of the job (which executes the command), if not then exit out of the script.&lt;BR /&gt;Do you see what I mean?&lt;BR /&gt;&lt;BR /&gt;-Hazem</description>
      <pubDate>Fri, 05 Mar 2004 10:26:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron/m-p/3210644#M168452</guid>
      <dc:creator>Hazem Mahmoud_3</dc:creator>
      <dc:date>2004-03-05T10:26:32Z</dc:date>
    </item>
    <item>
      <title>Re: cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron/m-p/3210645#M168453</link>
      <description>The job needs to run every day and determine what day it is.&lt;BR /&gt;&lt;BR /&gt;A. Clay Stephenson has some great utilities that help you figure that out.  caljd.sh is on &lt;A href="http://www.hpux.ws/merijn" target="_blank"&gt;http://www.hpux.ws/merijn&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;I'm attaching a slightly out of date copy.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Fri, 05 Mar 2004 10:29:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron/m-p/3210645#M168453</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2004-03-05T10:29:12Z</dc:date>
    </item>
    <item>
      <title>Re: cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron/m-p/3210646#M168454</link>
      <description>Jerry,&lt;BR /&gt;&lt;BR /&gt;unfortunately the crontab positions are not all connected with and but or.&lt;BR /&gt;Use as Chris suggests.&lt;BR /&gt;&lt;BR /&gt;Michael&lt;BR /&gt;</description>
      <pubDate>Fri, 05 Mar 2004 10:33:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron/m-p/3210646#M168454</guid>
      <dc:creator>Michael Schulte zur Sur</dc:creator>
      <dc:date>2004-03-05T10:33:08Z</dc:date>
    </item>
    <item>
      <title>Re: cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron/m-p/3210647#M168455</link>
      <description>Hi Jerry,&lt;BR /&gt;&lt;BR /&gt;It cannot be done by default with cron. However, you can add that logic into your script to see if this day is first saturday and exit if not. Attached is a script that is to be prefixed to your orignal script. This checks if today is the day you specified via arguments. For ex.,&lt;BR /&gt;&lt;BR /&gt;$./croncheck.sh 1 2&lt;BR /&gt;Usage ./ck.cron: Week Weekday&lt;BR /&gt;Example: ./ck.cron 1 Fri - for first friday&lt;BR /&gt;Your schedule is error&lt;BR /&gt;$./croncheck 1  sat&lt;BR /&gt;Your schedule is notok&lt;BR /&gt;$./croncheck 1 fri&lt;BR /&gt;Your schedule is ok&lt;BR /&gt;&lt;BR /&gt;Edit the script and put exit instead of echoing MYSCHEDULE&amp;gt;&lt;BR /&gt;&lt;BR /&gt;Run the whole script (this script + your script) on every saturday with the arguments 'croncheck 1 sat'. It will exit on all other saturdays except first saturday.&lt;BR /&gt;&lt;BR /&gt;-Sri&lt;BR /&gt;</description>
      <pubDate>Fri, 05 Mar 2004 10:38:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron/m-p/3210647#M168455</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2004-03-05T10:38:22Z</dc:date>
    </item>
    <item>
      <title>Re: cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron/m-p/3210648#M168456</link>
      <description>The version of caljd.sh is not recent enough to solve this problem easily. The problem with trying to use cron on it's own it that the monthday and weekday fields do an OR and you intended an AND. As suggested, you need to run the script every Saturday and then use a mechanism to determine if it is ther correct Saturday.&lt;BR /&gt;&lt;BR /&gt;Actually, you probably want this to run at 00:00 SUNDAY rather than Saturday if I understand your question.&lt;BR /&gt;&lt;BR /&gt;I would change your crontab entry to:&lt;BR /&gt;0 0 * * 0 &lt;BR /&gt;&lt;BR /&gt;and then add this to your cronjob script. Make sure that PATH is set and exported because cron's environment is intentionally sparse.&lt;BR /&gt;&lt;BR /&gt;I think I understand your question. You require that BOTH Saturday and Sunday be the first instance in this month. If Sunday is the 1st Sunday of the current month but Saturday is the last Saturday of the prior month, you do not want to trigger any action.&lt;BR /&gt;&lt;BR /&gt;Caljd.sh -N's output indicates the occurrance of a current weekday withing the month (1 = 1st; 2 = 2nd; ...)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;This should be added in your cronjob script:&lt;BR /&gt;&lt;BR /&gt;if [[ $(caljd.sh -N) -eq 1 &amp;amp;&amp;amp; $(caljd.sh -N -p 1) -eq 1 ]]&lt;BR /&gt; then&lt;BR /&gt;   echo "Do your thing"&lt;BR /&gt; else&lt;BR /&gt;   echo "Exit; do nothing"&lt;BR /&gt; fi&lt;BR /&gt;&lt;BR /&gt;We are checking the occurance of today's weekday (-N) and also the occurance of the previous day (-N -p 1). Only if both equal 1 do we proceed.&lt;BR /&gt;&lt;BR /&gt;Invoke as caljd.sh -u for full usage.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 05 Mar 2004 10:48:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron/m-p/3210648#M168456</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2004-03-05T10:48:13Z</dc:date>
    </item>
    <item>
      <title>Re: cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron/m-p/3210649#M168457</link>
      <description>ACS,&lt;BR /&gt;&lt;BR /&gt;why would you want to run the script on sunday? Remember the Vulcan High Councel does not believe in time travel! ;-)&lt;BR /&gt;&lt;BR /&gt;Michael&lt;BR /&gt;</description>
      <pubDate>Fri, 05 Mar 2004 10:56:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron/m-p/3210649#M168457</guid>
      <dc:creator>Michael Schulte zur Sur</dc:creator>
      <dc:date>2004-03-05T10:56:39Z</dc:date>
    </item>
    <item>
      <title>Re: cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron/m-p/3210650#M168458</link>
      <description>Chris, good answer. Simple method.&lt;BR /&gt;&lt;BR /&gt;Thanks all.</description>
      <pubDate>Fri, 05 Mar 2004 11:14:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron/m-p/3210650#M168458</guid>
      <dc:creator>jerry1</dc:creator>
      <dc:date>2004-03-05T11:14:52Z</dc:date>
    </item>
  </channel>
</rss>

