<?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 Question in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/4884051#M401093</link>
    <description>You can do some tricky calculation, like just take last date of month as 30 &amp;amp; 31, you can do it monthwise...&lt;BR /&gt;DO a minus on this day and see what is the day..using some date format, if the day turns out to be friday, you can execute the command..&lt;BR /&gt;&lt;BR /&gt;date would be 31,30,28&lt;BR /&gt;&lt;BR /&gt;do 31 - 5,4,3,2,1,0...see what it returns..execute ur script if it is friday...&lt;BR /&gt;you can divide the script in 3parts probably..and call from a small script in cron..&lt;BR /&gt;&lt;BR /&gt;Hope it helps&lt;BR /&gt;Thanks and regards&lt;BR /&gt;Prashant</description>
    <pubDate>Fri, 04 Feb 2005 09:57:12 GMT</pubDate>
    <dc:creator>Prashant Zanwar_4</dc:creator>
    <dc:date>2005-02-04T09:57:12Z</dc:date>
    <item>
      <title>Cron Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/4884042#M401084</link>
      <description>How do we format this this in the crontab file?&lt;BR /&gt;&lt;BR /&gt;Run "/scripts/backup" every last friday of the month at 6:00am ??&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;f.halili</description>
      <pubDate>Thu, 03 Feb 2005 16:41:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/4884042#M401084</guid>
      <dc:creator>f. halili</dc:creator>
      <dc:date>2005-02-03T16:41:38Z</dc:date>
    </item>
    <item>
      <title>Re: Cron Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/4884043#M401085</link>
      <description>The tricky part is the last friday of the month.&lt;BR /&gt;&lt;BR /&gt;What you should do is run a script every friday and use caljs.sh, an A. Clay Stepenson invention to determine if it is ineed the last friday of the month and go forward with the backup.&lt;BR /&gt;&lt;BR /&gt;Shell version:&lt;BR /&gt;&lt;A href="http://www.hpux.ws/merijn/caljd-2.23.sh" target="_blank"&gt;http://www.hpux.ws/merijn/caljd-2.23.sh&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Perl version&lt;BR /&gt;&lt;A href="http://www.hpux.ws/merijn/caljd-2.2.pl" target="_blank"&gt;http://www.hpux.ws/merijn/caljd-2.2.pl&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;crontab entry:&lt;BR /&gt;&lt;BR /&gt;* * * * 5 /command &lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Thu, 03 Feb 2005 16:59:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/4884043#M401085</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2005-02-03T16:59:19Z</dc:date>
    </item>
    <item>
      <title>Re: Cron Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/4884044#M401086</link>
      <description>Well....there are only twelve last Friday's of the month each year.&lt;BR /&gt;&lt;BR /&gt;Put each one on a different line (12 lines in all)</description>
      <pubDate>Thu, 03 Feb 2005 17:07:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/4884044#M401086</guid>
      <dc:creator>James A. Donovan</dc:creator>
      <dc:date>2005-02-03T17:07:41Z</dc:date>
    </item>
    <item>
      <title>Re: Cron Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/4884045#M401087</link>
      <description>Using the aforementioned caljd.sh script this is easy. You run you cronjob every Friday and the script itself determines if this is the last Friday by seeing if today and 7 days from now are in a different month. Your should set and export PATH in your script to include the location of caljd.sh or use full pathnames:&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 -M) != $(caljd.sh -n 7 -M) ]]&lt;BR /&gt;  then&lt;BR /&gt;    echo "Do your thing; it's the last Friday"&lt;BR /&gt;  fi&lt;BR /&gt;</description>
      <pubDate>Thu, 03 Feb 2005 17:30:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/4884045#M401087</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-02-03T17:30:03Z</dc:date>
    </item>
    <item>
      <title>Re: Cron Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/4884046#M401088</link>
      <description>This is only this you need&lt;BR /&gt;#crontab -e&lt;BR /&gt;# Minute Hour MonthDay Month Weekday Command&lt;BR /&gt;# ----------------------------------------------------------&lt;BR /&gt;0 06 * * 5 /sbin/sh your_path/script&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Notes: 0=Sunday, 1=Mon ...5 =Friday&lt;BR /&gt;tienna</description>
      <pubDate>Fri, 04 Feb 2005 04:20:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/4884046#M401088</guid>
      <dc:creator>Nguyen Anh Tien</dc:creator>
      <dc:date>2005-02-04T04:20:58Z</dc:date>
    </item>
    <item>
      <title>Re: Cron Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/4884047#M401089</link>
      <description>Nguyen Anh Tien  is realy right :)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 04 Feb 2005 07:17:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/4884047#M401089</guid>
      <dc:creator>Ivajlo Yanakiev</dc:creator>
      <dc:date>2005-02-04T07:17:44Z</dc:date>
    </item>
    <item>
      <title>Re: Cron Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/4884048#M401090</link>
      <description>How do you figure that's right?  It looks to me like that would run every Friday.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Fri, 04 Feb 2005 07:36:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/4884048#M401090</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2005-02-04T07:36:25Z</dc:date>
    </item>
    <item>
      <title>Re: Cron Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/4884049#M401091</link>
      <description>&lt;BR /&gt;If you could live with the 4th Friday every month instead of the last Friday, you could do:&lt;BR /&gt;0 06 21-28 * 5 /scripts_dir/backup&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 04 Feb 2005 09:33:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/4884049#M401091</guid>
      <dc:creator>Doug Kratky</dc:creator>
      <dc:date>2005-02-04T09:33:20Z</dc:date>
    </item>
    <item>
      <title>Re: Cron Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/4884050#M401092</link>
      <description>This suggested solution &lt;BR /&gt;0 06 21-28 * 5 /scripts_dir/backup&lt;BR /&gt;will certainly run on the last Friday of the month but sadly it will also run on every other Friday of the month as well. In addition, it will also execute the command every doy of the month from the 21st to the 28th. When weekdays and monthdays are specified in cron, the result is not a logical AND but is rather a logical OR.&lt;BR /&gt; &lt;BR /&gt;Use the solution I suggested earlier.</description>
      <pubDate>Fri, 04 Feb 2005 09:56:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/4884050#M401092</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-02-04T09:56:26Z</dc:date>
    </item>
    <item>
      <title>Re: Cron Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/4884051#M401093</link>
      <description>You can do some tricky calculation, like just take last date of month as 30 &amp;amp; 31, you can do it monthwise...&lt;BR /&gt;DO a minus on this day and see what is the day..using some date format, if the day turns out to be friday, you can execute the command..&lt;BR /&gt;&lt;BR /&gt;date would be 31,30,28&lt;BR /&gt;&lt;BR /&gt;do 31 - 5,4,3,2,1,0...see what it returns..execute ur script if it is friday...&lt;BR /&gt;you can divide the script in 3parts probably..and call from a small script in cron..&lt;BR /&gt;&lt;BR /&gt;Hope it helps&lt;BR /&gt;Thanks and regards&lt;BR /&gt;Prashant</description>
      <pubDate>Fri, 04 Feb 2005 09:57:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/4884051#M401093</guid>
      <dc:creator>Prashant Zanwar_4</dc:creator>
      <dc:date>2005-02-04T09:57:12Z</dc:date>
    </item>
    <item>
      <title>Re: Cron Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/4884052#M401094</link>
      <description>My solution:&lt;BR /&gt;&lt;BR /&gt;Crontab (starts custom script every friday) :&lt;BR /&gt;0 6 * * 5 /scripts/backup_start&lt;BR /&gt;&lt;BR /&gt;Script &lt;BACKUP_START&gt; (checks condition: if today is last friday then execute main script):&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;Last_day_in_month=`cal | sed '/^$/d' | tail -1 | head -1 | awk '{print $NF}'`&lt;BR /&gt;Today=`date +%d`&lt;BR /&gt;if [ `expr $Today + 7` \=&amp;gt; `expr $Last_day_in_month` ]&lt;BR /&gt;then&lt;BR /&gt;        &lt;RUN_THE_SCRIPT&gt;&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Sergejs&lt;/RUN_THE_SCRIPT&gt;&lt;/BACKUP_START&gt;</description>
      <pubDate>Fri, 04 Feb 2005 11:06:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/4884052#M401094</guid>
      <dc:creator>Sergejs Svitnevs</dc:creator>
      <dc:date>2005-02-04T11:06:06Z</dc:date>
    </item>
    <item>
      <title>Re: Cron Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/4884053#M401095</link>
      <description>Another variation would require adding a few lines to the backup script and 3 cron entries.&lt;BR /&gt;&lt;BR /&gt;# Check if day is Fri&lt;BR /&gt;today=$(date +%a)&lt;BR /&gt;if [ "$today" != "Fri" ]&lt;BR /&gt;then&lt;BR /&gt;        echo "Okay, will not run now since today is $today and not Fri."&lt;BR /&gt;        exit&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;00 06 25-31 1,3,5,7,8,10,12 * /scripts/backup&lt;BR /&gt;00 06 24-30 4,6,9,11        * /scripts/backup&lt;BR /&gt;00 06 22-28 2               * /scripts/backup&lt;BR /&gt;&lt;BR /&gt;This would still require a method to deal with February when it has 29 days with the 29th on a Friday.&lt;BR /&gt;&lt;BR /&gt;Switching to the first Friday of the month let's you just run the script on days 1 through 7.&lt;BR /&gt;&lt;BR /&gt;Marlou</description>
      <pubDate>Fri, 04 Feb 2005 16:01:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/4884053#M401095</guid>
      <dc:creator>Marlou Everson</dc:creator>
      <dc:date>2005-02-04T16:01:10Z</dc:date>
    </item>
    <item>
      <title>Re: Cron Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/4884054#M401096</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I think Clay's solution is the simplest and you can be sure that it will run on the last Friday of the month.  Why complicate it, right?</description>
      <pubDate>Sun, 06 Feb 2005 21:54:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/4884054#M401096</guid>
      <dc:creator>Anthony Villanueva</dc:creator>
      <dc:date>2005-02-06T21:54:52Z</dc:date>
    </item>
    <item>
      <title>Re: Cron Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/4884055#M401097</link>
      <description>thanks for all the inputs.</description>
      <pubDate>Mon, 07 Feb 2005 16:18:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/4884055#M401097</guid>
      <dc:creator>f. halili</dc:creator>
      <dc:date>2005-02-07T16:18:24Z</dc:date>
    </item>
  </channel>
</rss>

