<?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: scheduling cron job in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/scheduling-cron-job/m-p/2558170#M820109</link>
    <description>My previous solution is in error.  &lt;BR /&gt;&lt;BR /&gt;if .RUN then&lt;BR /&gt;  process&lt;BR /&gt;  mv .RUN .SKIP&lt;BR /&gt;  exit&lt;BR /&gt;else&lt;BR /&gt;  mv .SKIP .RUN&lt;BR /&gt;fi&lt;BR /&gt;exit</description>
    <pubDate>Mon, 30 Jul 2001 21:17:09 GMT</pubDate>
    <dc:creator>Jack Werner</dc:creator>
    <dc:date>2001-07-30T21:17:09Z</dc:date>
    <item>
      <title>scheduling cron job</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scheduling-cron-job/m-p/2558165#M820104</link>
      <description>Is it possible to schedule a cron job to run every OTHER Saturday? I can't set it up to use 2 days, like the 1st &amp;amp; 15th, due to circumstances that are too lengthy to explain.&lt;BR /&gt;Thanx in advance for any help.</description>
      <pubDate>Fri, 27 Jul 2001 18:26:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scheduling-cron-job/m-p/2558165#M820104</guid>
      <dc:creator>Paul Wright</dc:creator>
      <dc:date>2001-07-27T18:26:31Z</dc:date>
    </item>
    <item>
      <title>Re: scheduling cron job</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scheduling-cron-job/m-p/2558166#M820105</link>
      <description>He paul,&lt;BR /&gt;You can do this in your script. If you running any program then call that prgram from script.&lt;BR /&gt;Now run your program from cron for all sat. and it will run only on even sat.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;set WEEK = `date +%U`&lt;BR /&gt;@ ALTWK = $WEEK % 2&lt;BR /&gt;switch ($ALTWK)&lt;BR /&gt;  case 0:&lt;BR /&gt;    set SET = 1&lt;BR /&gt;    breaksw&lt;BR /&gt;  case 1:&lt;BR /&gt;    set SET = 2&lt;BR /&gt;    breaksw&lt;BR /&gt;endsw&lt;BR /&gt;if ( $SET == 1 )&lt;BR /&gt;    call program;&lt;BR /&gt;else&lt;BR /&gt;    exit 0;&lt;BR /&gt;endif&lt;BR /&gt;</description>
      <pubDate>Fri, 27 Jul 2001 18:35:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scheduling-cron-job/m-p/2558166#M820105</guid>
      <dc:creator>Sachin Patel</dc:creator>
      <dc:date>2001-07-27T18:35:04Z</dc:date>
    </item>
    <item>
      <title>Re: scheduling cron job</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scheduling-cron-job/m-p/2558167#M820106</link>
      <description>Hi Paul,&lt;BR /&gt;If I understand you , you want not that the script run in 1st and 15th saturday of the year, correct ??&lt;BR /&gt;If I correct, you will can to note every &lt;BR /&gt;saturdays of the year and put it in the cron&lt;BR /&gt;line. For exmple this month ( July ) have a&lt;BR /&gt;four saturdays ( 7 14 21 28 ) then you crontab line will stay, for example, as below :&lt;BR /&gt;&lt;BR /&gt;0 4 14,21,28,.....* *  /dir/comand&lt;BR /&gt;&lt;BR /&gt;The crontab will execute the more restrictive comand, in this case, it ignored the * * and &lt;BR /&gt;run only in the days that was specify.&lt;BR /&gt;&lt;BR /&gt;I hope this help.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Abel Berger&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 27 Jul 2001 19:29:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scheduling-cron-job/m-p/2558167#M820106</guid>
      <dc:creator>Abel Berger</dc:creator>
      <dc:date>2001-07-27T19:29:22Z</dc:date>
    </item>
    <item>
      <title>Re: scheduling cron job</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scheduling-cron-job/m-p/2558168#M820107</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;Another way to do it is to put it into a script that uses 'at' to reschedule itself each time it runs.&lt;BR /&gt;&lt;BR /&gt;You could have a script named 'myscript' that looks like this:&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;&lt;BR /&gt;# myscript&lt;BR /&gt;&lt;BR /&gt;# Start of script&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;# End of script&lt;BR /&gt;&lt;BR /&gt;echo "sh /home/users/myhome/myscript" | at 1900 saturday next +3 weeks&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The next parameter in 'at' defaults to 'next +1', so to get it set two weeks out you would do 'next +3'.&lt;BR /&gt;&lt;BR /&gt;Just another way to do it.&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 27 Jul 2001 20:20:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scheduling-cron-job/m-p/2558168#M820107</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2001-07-27T20:20:03Z</dc:date>
    </item>
    <item>
      <title>Re: scheduling cron job</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scheduling-cron-job/m-p/2558169#M820108</link>
      <description>Schedule it to run on day "6" every week. You will get into a problem running every other week in a month. Some month's have 5 Saturdays.  If you simply want to run every-other week regardless of the month, then  test the existence of a file and exit if present.(eg $HOME/.BYPASS), otherwise, touch $HOME/.BYPASS and run the script.</description>
      <pubDate>Mon, 30 Jul 2001 21:02:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scheduling-cron-job/m-p/2558169#M820108</guid>
      <dc:creator>Jack Werner</dc:creator>
      <dc:date>2001-07-30T21:02:05Z</dc:date>
    </item>
    <item>
      <title>Re: scheduling cron job</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scheduling-cron-job/m-p/2558170#M820109</link>
      <description>My previous solution is in error.  &lt;BR /&gt;&lt;BR /&gt;if .RUN then&lt;BR /&gt;  process&lt;BR /&gt;  mv .RUN .SKIP&lt;BR /&gt;  exit&lt;BR /&gt;else&lt;BR /&gt;  mv .SKIP .RUN&lt;BR /&gt;fi&lt;BR /&gt;exit</description>
      <pubDate>Mon, 30 Jul 2001 21:17:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scheduling-cron-job/m-p/2558170#M820109</guid>
      <dc:creator>Jack Werner</dc:creator>
      <dc:date>2001-07-30T21:17:09Z</dc:date>
    </item>
    <item>
      <title>Re: scheduling cron job</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scheduling-cron-job/m-p/2558171#M820110</link>
      <description>Hi Paul,&lt;BR /&gt;&lt;BR /&gt;I think I have the perfect way to do this and it uses a technique that I have used for many years. Use the attached script to return a Julian Day (~ No. of days since 01/01/4712 BCE - Astronomers use a variant of this to make calculations simple).&lt;BR /&gt;You then divide this by 7 to get get the week number. Mod this by 2 and you get either 1 or 0. The advantage of this, is that it truly does work every other week. The %U format operator in date sometimes does not work as expected because some years have 53 weeks and most have 52.&lt;BR /&gt;Your cron entry should of course fire off each Saturday and then call a script something like this: (caljd.sh is the attached script)&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;JDAY=`/usr/local/bin/caljd.sh`&lt;BR /&gt;JWK=$((${JDAY} / 7))&lt;BR /&gt;IS_WK=$((JWK} % 2))&lt;BR /&gt;if [ ${IS_WK} -eq 1 ]&lt;BR /&gt;  then&lt;BR /&gt;    echo "Do your Stuff Goes here"&lt;BR /&gt;  else&lt;BR /&gt;    echo "Do nothing"&lt;BR /&gt;  fi&lt;BR /&gt;&lt;BR /&gt;This will absolutely work, year in, year out.&lt;BR /&gt;&lt;BR /&gt;Depending on your application, you might actually fire off your application on 0 rather than 1 but you get the idea.&lt;BR /&gt;&lt;BR /&gt;Regards, Clay</description>
      <pubDate>Mon, 30 Jul 2001 21:27:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scheduling-cron-job/m-p/2558171#M820110</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2001-07-30T21:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: scheduling cron job</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scheduling-cron-job/m-p/2558172#M820111</link>
      <description>A. Clay - &lt;BR /&gt;I've been using your method for months to automate a job I have to run on alternate tuesdays.. Today it failed.&lt;BR /&gt;It ran as usual on 1/7 and 1/21 but didn't fire off the job today 2/4/03.. ? &lt;BR /&gt;Any ideas why? &lt;BR /&gt;thanks so much! &lt;BR /&gt;&lt;BR /&gt;John Henrikson &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 04 Feb 2003 15:35:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scheduling-cron-job/m-p/2558172#M820111</guid>
      <dc:creator>John Henrikson</dc:creator>
      <dc:date>2003-02-04T15:35:40Z</dc:date>
    </item>
    <item>
      <title>Re: scheduling cron job</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scheduling-cron-job/m-p/2558173#M820112</link>
      <description>Because you are running a very old version of caljd.sh that had a bug. I missed a floating-point divide (rather that integer).&lt;BR /&gt;&lt;BR /&gt;Use this version and all should be well. In the comments sectiopn, I indicate my dumb error.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 04 Feb 2003 15:49:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scheduling-cron-job/m-p/2558173#M820112</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-02-04T15:49:43Z</dc:date>
    </item>
    <item>
      <title>Re: scheduling cron job</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scheduling-cron-job/m-p/2558174#M820113</link>
      <description>Thanks so much!!! &lt;BR /&gt;&lt;BR /&gt;John Henrikson &lt;BR /&gt;</description>
      <pubDate>Tue, 04 Feb 2003 15:52:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scheduling-cron-job/m-p/2558174#M820113</guid>
      <dc:creator>John Henrikson</dc:creator>
      <dc:date>2003-02-04T15:52:09Z</dc:date>
    </item>
    <item>
      <title>Re: scheduling cron job</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scheduling-cron-job/m-p/2558175#M820114</link>
      <description>Hi Paul,&lt;BR /&gt;&lt;BR /&gt;0 0 * * * 6 /usr/local/bin/run_every_two_weeks&lt;BR /&gt;&lt;BR /&gt;---------------&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;## Run every_two_weeks_script&lt;BR /&gt;&lt;BR /&gt;# Get current weeknumber&lt;BR /&gt;week=`cat /usr/local/etc/week_number`&lt;BR /&gt;&lt;BR /&gt;# Only for the first time when $week is not yet set :&lt;BR /&gt;if [ -z $week ]&lt;BR /&gt;  then&lt;BR /&gt;    week="0"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if [ $week -eq "1" ]&lt;BR /&gt;  then&lt;BR /&gt;    /run/this/script&lt;BR /&gt;    echo "0" &amp;gt;/usr/local/etc/week_number&lt;BR /&gt;  else&lt;BR /&gt;    echo "1" &amp;gt;/usr/local/etc/week_number&lt;BR /&gt;fi&lt;BR /&gt;# ---------------------------&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Regs David&lt;BR /&gt;</description>
      <pubDate>Tue, 04 Feb 2003 15:58:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scheduling-cron-job/m-p/2558175#M820114</guid>
      <dc:creator>David_246</dc:creator>
      <dc:date>2003-02-04T15:58:25Z</dc:date>
    </item>
  </channel>
</rss>

