cron job on 3rd sunday of every month


 
Thread Tools Search this Thread
Operating Systems AIX cron job on 3rd sunday of every month
# 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..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Run script on every last sunday of the month

Hi ALL, I have been testing this script to run for every last Sunday of the month,looks like month which have 5 sunday (july 2016 )is not passing this and failing every time. Here is what I am using, current_date=31 echo " CURRENT DAY -> $current_date" if ... (2 Replies)
Discussion started by: netdbaind
2 Replies

2. Shell Programming and Scripting

Trigger the script if it is first sunday of the quarterly month

Hello All, I have script which needs to be scheduled in crontab which needs to be run only on the first sunday of the quarterly months (March, June, September,Dec). Can anyone please help me out on this. Thanks, Arun. (13 Replies)
Discussion started by: Arun1992
13 Replies

3. Shell Programming and Scripting

How to setup cronjob 3rd sunday of every month?

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... (7 Replies)
Discussion started by: netdbaind
7 Replies

4. Shell Programming and Scripting

How to get first sunday of the month?

Hi, Please can someone help me in getting first sunday date of a month. i_year=`date +%Y` ny_first_sun_nov=`cal 10 $i_year | sed '/^$/d' |head -3 |tail -1| rev | cut -c1` This works good if the first sunday has a value but not if it is blank and first sunday falls on second week. ... (17 Replies)
Discussion started by: infyanurag
17 Replies

5. UNIX for Dummies Questions & Answers

[Solved] Cron - job to run every 3rd Friday of the month only

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... (2 Replies)
Discussion started by: kaibiganmi
2 Replies

6. Shell Programming and Scripting

cron job to run on second to last friday each month

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... (0 Replies)
Discussion started by: lupin..the..3rd
0 Replies

7. UNIX for Dummies Questions & Answers

How to Set up a cronjob On 4th Sunday of every Month?

How to Set up a cronjob which will run On 4th Sunday of every Month at 8:00 PM :( (11 Replies)
Discussion started by: tp2115
11 Replies

8. Shell Programming and Scripting

Crontab job to run every sunday

Hello, I wanted to run one of my shell script for every sunday at 5PM. Here is the crontab entry i am using.. 00 17 * * 0 /inventory/update.sh > /inventory/update.log 2>&1 The job is not kicking on sunday at the specified time.. Am i missing anthing? Any help is appreciated... (2 Replies)
Discussion started by: govindts
2 Replies

9. UNIX for Dummies Questions & Answers

Cron job -- to execute at every first Sunday of every month

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 (2 Replies)
Discussion started by: shanemcmahon
2 Replies

10. UNIX for Dummies Questions & Answers

setting up cron job for month end week report

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... (3 Replies)
Discussion started by: Bhups
3 Replies
Login or Register to Ask a Question