cron job on 3rd sunday of every month

Tags
cron, solved

 
Thread Tools Search this Thread
# 1  
Old 10-15-2018
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 12:00 PM..
# 2  
Old 10-16-2018
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 02:53 PM..

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

More UNIX and Linux Forum Topics You Might Find Helpful
Run script on every last sunday of the month netdbaind Shell Programming and Scripting 2 07-21-2016 08:46 PM
Trigger the script if it is first sunday of the quarterly month Arun1992 Shell Programming and Scripting 13 12-31-2015 01:45 AM
Cron job - Need to run Cron every quarter at particular time System Admin 77 Shell Programming and Scripting 5 11-25-2014 02:09 PM
How to setup cronjob 3rd sunday of every month? netdbaind Shell Programming and Scripting 7 10-30-2014 08:47 AM
How to create a cronjob for the 3rd business day of every month? AReddy UNIX for Dummies Questions & Answers 2 10-04-2013 03:33 PM
How to get first sunday of the month? infyanurag Shell Programming and Scripting 17 05-08-2013 05:08 PM
[Solved] Cron - job to run every 3rd Friday of the month only kaibiganmi UNIX for Dummies Questions & Answers 2 11-09-2012 06:01 AM
Cron for an alternate sunday user` Shell Programming and Scripting 9 06-05-2012 10:12 PM
cron job to run on second to last friday each month lupin..the..3rd Shell Programming and Scripting 0 03-30-2012 03:58 PM
Autosys job run on Sunday anupdas UNIX for Advanced & Expert Users 2 04-04-2011 08:52 PM
How to Set up a cronjob On 4th Sunday of every Month? tp2115 UNIX for Dummies Questions & Answers 11 08-25-2010 01:05 PM
Crontab job to run every sunday govindts Shell Programming and Scripting 2 12-15-2008 05:01 PM
Crontab job on sunday with two week interval tan.pham AIX 4 03-20-2008 04:50 AM
Cron job -- to execute at every first Sunday of every month shanemcmahon UNIX for Dummies Questions & Answers 2 05-04-2007 12:34 AM
setting up cron job for month end week report Bhups UNIX for Dummies Questions & Answers 3 04-07-2006 06:42 AM