Re: crontab 4th Tuesday of month

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 07/28/2012 07:03 AM, Frank Murphy wrote:
> I thought the last tuesday would be covered by above.
> But it has run everyday since 22nd.

Hi,

There's no way to accomplish this via crontab itself.  You'll need a
little help by means of a script.

This works:

1)  create the following script. Let's call it tuesday-check.sh:

#/bin/sh
[ `date +%m` -ne `date -d "+7 days" +%m` ] && your-actual-command.sh


2) create a crontab entry for the above script so that it runs every
Tuesday (yes I know you want the last Tuesday;  the script will
precisely check that):

15 18 * * 2 /root/bin/tuesday-check.sh


Explanation:

date +%m
...returns the *month number* for today

date -d "+7 days" +%m
...returns the "month number" for this day *one week ahead*


For example, if I were to run this on the last Saturday of the month
(today the 28th):

- the first command would return "7".
- the second command would return "8" because the NEXT Saturday is
already August.

Because both of the returned numbers are different (7 and 8) the command
will run.

HTH,
Jorge
-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org


[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux