cron job on 3rd sunday of every month


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
cron job on 3rd sunday of every month

Hi,

Actually scheduled my test scripts on test severs as shown below. They are supposed to run on 3rd sunday of every month.
Unfortunately it ran on 2nd sunday of the month (suspecting that it will run every sunday). I am sorry if I miss something. Could you please let me know if I did any mistake here.



15 2 15,16,17,18,19,20,21 * 0 /mydir/myscriptstop.sh


content of "/mydir/myscriptstop.sh"

Code:
#!/usr/bin/ksh
# exit if today is not Sunday
dow=`date +%w`
[ $dow -eq 0 ] || exit
# the actual script is below

/home/user1/stop.sh   # example

15 4 15,16,17,18,19,20,21 * 0 /mydir/myscriptstart.sh

content of "/mydir/myscriptstart.sh"

Code:
#!/usr/bin/ksh

# exit if today is not Sunday
dow=`date +%w`
[ $dow -eq 0 ] || exit
# the actual script is below

/home/user1/start.sh   # example

I read the man page as well. But not able to notice.
IBM Knowledge Center Error

I am suspecting that,
AIX cron is evaluating "weekday" first and going with the flow and not considering the "day of the month".

please look into this.

------ Post updated at 10:29 AM ------

my bad, sorry..I found the mistake.


I was trying to run cron using "weekday" code...


15 2 15,16,17,18,19,20,21 * * /mydir/myscriptstop.sh



15 4 15,16,17,18,19,20,21 * * /mydir/myscriptstart.sh



I believe these should work. ty




Moderator's Comments:
Mod Comment Don't hijack others' threads!
Moved to its own thread, trying to invent a meaningful title

Last edited by RudiC; 10-15-2018 at 11:00 AM..
# 2  
Yes, your fix is correct. It was treated as an OR: run on the given days OR on sundays. (In the math sense. In casual speach you say AND.)

Last edited by MadeInGermany; 10-16-2018 at 01:53 PM..
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
How to setup cronjob 3rd sunday of every month?
netdbaind
Hi All, I need to set up cronjob for every third sunday of the month. here i have seen one example for 4th sunday for every month in another post and it looks perfect.can anyone please help me to understand this and help me to get the setup for third sunday of every month.Thanks. this is...... Shell Programming and Scripting
7
Shell Programming and Scripting
[Solved] Cron - job to run every 3rd Friday of the month only
kaibiganmi
Hi Expert Please help me to set a cron job schedule, Ihave a job that run every 3rd Friday of the month at 1030am. I tried to set up like this, but the job still runs every friday at 1030am. I want the job to run every 3rd Friday of the month at 1030am only 30 10 15,16,17,18,19,20,21...... UNIX for Dummies Questions & Answers
2
UNIX for Dummies Questions & Answers
cron job to run on second to last friday each month
lupin..the..3rd
I needed a cron job to run on the second to last friday of every month. Our servers are running HP-UX, and the HP-UX date command is pretty basic and does not have all of the fancy options that Linux date command does, and it does not have the ability at all to return future dates. So I had to...... Shell Programming and Scripting
0
Shell Programming and Scripting
Cron job -- to execute at every first Sunday of every month
shanemcmahon
Dear all How can I schedule the cronjob to be run sometime at every first Sunday at every month? I have the edit the cronjob every month now, thanks... UNIX for Dummies Questions & Answers
2
UNIX for Dummies Questions & Answers
setting up cron job for month end week report
Bhups
Hi all, Needs your help in scheduling a cron job for the below mentioned requirement. Just let me know if anybody has a similar job running as mentioned below: Month end reports - Report of all items created in a parent table that were created during the week. Presently this report runs...... UNIX for Dummies Questions & Answers
3
UNIX for Dummies Questions & Answers
UNIX and Linux

Unix (trademarked as the UNIX certification mark) is a very mature family of multitasking, multiuser computer operating systems that evolved from the original AT&T Unix. Unix development starting in the 1970s by legendary Bell Labs programmers Ken Thompson, Dennis Ritchie, and others. Unix was first targeted for the Bell System and AT&T licensed Unix to outside parties. In the 1970s time period, this lead to a variety of for-profit as well as not-for-profit Unix variants.
In the early days, this included the University of California, Berkeley (BSD), Microsoft (Xenix), IBM (AIX), and Sun Microsystems (Solaris). In the early 1990s, AT&T sold their Unix rights to Novell. In 1995 Novell sold their Unix business to the Santa Cruz Operation (SCO). The UNIX trademark was passed to The Open Group, a "neutral" industry consortium. The Open Group promoted the use of the UNIX trademark for certified operating systems that comply with the Single UNIX Specification (SUS). In 2014 Apple's macOS became the Unix version with the largest global install base and macOS remains the largest Unix-user base today.
Linux is a family of open source Unix-like operating systems based on the Linux kernel. The Linux kernel is an operating system kernel first released by Linus Torvalds on 17 September 1991. Linux distributions include the Linux kernel, system software and libraries. Popular free open source Linux distributions include Debian, Fedora, and Ubuntu. Commercial Linux distributions include Red Hat Enterprise Linux and SUSE Linux Enterprise Server. Linux may be freely modified and redistributed. Anyone on the planet may create a Linux distribution for any purpose.
Please enjoy and help our forum community by "showing your work" and posting your code, even when your code is not working as expected. To help others help you, please wrap your code blocks, sample input, sample output, error messages, and other data in CODE tags and wrap your short commands and short data objects in ICODE tags. We were all beginners in the beginning. If you have any questions about how to register or how to post, please contact us in Live Chat. Thank you and enjoy this "forever free" technical support community for UNIX, Linux and computer information technology in general.