Hi netdbaind,
The problem with your logic is that the last Sunday in a month is 22-28 in a month with 28 days, 23-29 in a month with 29 days, 24-30 in a month with 30 days and 25-31 in a month with 31 days. There is nothing that you have shown us in your code that determines whether or not you are in a leap year nor what month you're evaluating.
The code rdrtx1 suggested works in any locale where cal will print Sundays as the leftmost field on a line. You could guarantee that the output from cal will give you what you want no matter where in the world you run it if you change the first line to:
This User Gave Thanks to Don Cragun For This Post:
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)
I was to schedule a script in a crontab after every 15 days specically on every 2nd Sunday.
I know that i can schedule on basis of weekdays, but can it be done by skipping in between???:wall: (5 Replies)
Hello Experts,
I have a script which i want to run the on last day of every month.
let say I have backup.sh script which i want to run it every month last day.
Can anyone please help :confused:
thanks (4 Replies)
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)
Hi All,
I have a script, I want to make sure the script should check whether the day is sunday, only then it should run, if it is run other days it should check and exit the script.
Kindly help.
Thanks in Advance !! (41 Replies)
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)
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)
I am looking for a unix script which could run a job on 2, 4 and 7 working day of the month.
if the days are falling on the saturday/sunday. it should run on the next day.
Thank you.. (9 Replies)
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... (1 Reply)