Run cron on every second Saturday ??


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Run cron on every second Saturday ??
# 1  
Old 07-19-2012
Run cron on every second Saturday ??

Hi,

Can anyone help in editing CRON (OR) write a script to run another script every second saturday??
I tried to make use of DATE command to find the day but couldnt proceed further.

your help is highly appreciated!

Thanks,
Mahi
# 2  
Old 07-19-2012
Perhaps you could set up a job to run between 8th and 14th of each month, and check for Saturday in the script.

Code:
0 3 8-14 * * # pick your own time

Code:
[ $(date '+%w') -eq 6 ] || exit

# 3  
Old 07-19-2012
Hi,

Use the following cron entry,

Code:
* * 8-14 * 6 /path_to_script

The first two asteriscs should be replaced with the minute and hour that the script is to run.

Regards

Dave

Moderator's Comments:
Mod Comment When both monthday and weekday are specified in crontab they are cumulative.
Common mistake.
methyl

Last edited by methyl; 07-19-2012 at 10:09 AM..
# 4  
Old 07-19-2012
That won't work.

It will run when either of those criteria (8-14 of the month or day 6 of the week) are matched.
# 5  
Old 07-19-2012
Run cron on every second Saturday ??

Scott,

Thanks for the inputs, but i need to skip 3rd saturday and run it on fourth saturday, like i should run script only on even numbered saturdays. Hope its clear for you.

Thanks again
# 6  
Old 07-19-2012
Absolutely right guys, I should have known - I've walked into that one once before even if it was a long tome ago.

Sorry for the incorrect info.

Regards

Dave
# 7  
Old 07-19-2012
Well, as the fourth saturday can only happen from the 22nd...

Code:
0 3 8-14,22-28 * *

Code:
$ cal 2012
                             2012

      January               February               March
Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
 1  2  3  4  5  6  7            1  2  3  4               1  2  3
 8  9 10 11 12 13 14   5  6  7  8  9 10 11   4  5  6  7  8  9 10
15 16 17 18 19 20 21  12 13 14 15 16 17 18  11 12 13 14 15 16 17
22 23 24 25 26 27 28  19 20 21 22 23 24 25  18 19 20 21 22 23 24
29 30 31              26 27 28 29           25 26 27 28 29 30 31
                                            
       April                  May                   June
Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
 1  2  3  4  5  6  7         1  2  3  4  5                  1  2
 8  9 10 11 12 13 14   6  7  8  9 10 11 12   3  4  5  6  7  8  9
15 16 17 18 19 20 21  13 14 15 16 17 18 19  10 11 12 13 14 15 16
22 23 24 25 26 27 28  20 21 22 23 24 25 26  17 18 19 20 21 22 23
29 30                 27 28 29 30 31        24 25 26 27 28 29 30
                                            
        July                 August              September
Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
 1  2  3  4  5  6  7            1  2  3  4                     1
 8  9 10 11 12 13 14   5  6  7  8  9 10 11   2  3  4  5  6  7  8
15 16 17 18 19 20 21  12 13 14 15 16 17 18   9 10 11 12 13 14 15
22 23 24 25 26 27 28  19 20 21 22 23 24 25  16 17 18 19 20 21 22
29 30 31              26 27 28 29 30 31     23 24 25 26 27 28 29
                                            30
      October               November              December
Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
    1  2  3  4  5  6               1  2  3                     1
 7  8  9 10 11 12 13   4  5  6  7  8  9 10   2  3  4  5  6  7  8
14 15 16 17 18 19 20  11 12 13 14 15 16 17   9 10 11 12 13 14 15
21 22 23 24 25 26 27  18 19 20 21 22 23 24  16 17 18 19 20 21 22
28 29 30 31           25 26 27 28 29 30     23 24 25 26 27 28 29
                                            30 31

This User Gave Thanks to Scott For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Schedule the cron job for every 21day on saturday

Please guide me how to schedule the cron job to run on every Saturday at 6am with the interval of 21 days. (2 Replies)
Discussion started by: raghavendrajsv
2 Replies

2. Shell Programming and Scripting

Cron job - Need to run Cron every quarter at particular time

Hi, 1) If some job supposed to run on 1st of every month at 7 AM In cron job when we have a blackout on the 1st ( i.e when 1st falls on a sunday ) how can we make the job run the next business day? 2) How can we run a job on 25th of every quarter 7 AM(jan,apr,jul,oct) And if 25th... (5 Replies)
Discussion started by: System Admin 77
5 Replies

3. Shell Programming and Scripting

Who -u gives different output if run from cron than if run from terminal?

If I run 'who -u' interactively or from a script invoked through bash in a tty on my Ubuntu 12LTS box I get an output like this: testuser pts/0 Dec 9 02:32 . 2163 (host.xx.yy) running the same through cron I get: testuser pts/0 2012-12-09 02:32 00:05 2163... (2 Replies)
Discussion started by: latimer
2 Replies

4. Shell Programming and Scripting

cron to get executed on 2nd and 4th saturday of every month

Hi , i need to reboot a server during 2nd and 4th saturday every month. i have come up with the below cron 30 17 8-14 * * if ; then /rebootscript; fi # to reboot every second saturday 30 17 22-28 * * if ; then /rebootscript; fi # to reboot every fourth saturday I am wondering why it... (3 Replies)
Discussion started by: chidori
3 Replies

5. Shell Programming and Scripting

Run webpage from cron

I am running into a issue. How would you run a http:// page from cron? I tried directly from cron but no luck. I tried a sh script with no luck. #!/bin/sh PERL_PATH=/usr/bin/perl $PERL_PATH "/fullpath/cgi-bin/search/indexer.cgi?login=indexer&pwd=spider" and #!/bin/sh... (1 Reply)
Discussion started by: mrlayance
1 Replies

6. UNIX for Dummies Questions & Answers

cron does not appear to run

Hi everyone, I am having a problem with a cron, I am using Solaris 10 and need to run a php file every 5 minutes. I can run the file from the test user, but the cron does not seem to run. I do not see anything about it in /var/cron/log but see crons for other users running. What should I look... (10 Replies)
Discussion started by: atomicbits
10 Replies

7. UNIX for Advanced & Expert Users

How to scedule a script to be run on every second saturday in Month?

Hello Friends, In my project I have to schedule a script to be run on every second saturday (once in month). Can you please suggest what entry should I make in cron ? (5 Replies)
Discussion started by: sourabhsharma
5 Replies

8. Shell Programming and Scripting

Help with script - run by cron

Hello, I have a shell script that runs every minute to process incoming files delivered externally via SFTP to a directory. Basically the script works and processes the files however I get an error when a new file is delivered into the directory. Please see my script below. A new file is... (2 Replies)
Discussion started by: richo king
2 Replies

9. Shell Programming and Scripting

Check if a day eg: saturday is the Last saturday of the month!

Hi, I need to develop a script to check for the day. If the day is a Saturday then the script should check if the Saturday is the last Saturday of the month so that certain set of instruction can be executed is it is the last Saturday. I do not want to use the crontab as this needs to be part... (9 Replies)
Discussion started by: jobbyjoseph
9 Replies

10. UNIX for Dummies Questions & Answers

Where does cron run from?

I have a script in the same directory as some files and directories im trying to tar up and I have it run in cron. Well it runs but says it can't find the directories, you need to be in the directory where the script is for it to work. Here is my cron and script its crappy but it does the trick =).... (3 Replies)
Discussion started by: kingdbag
3 Replies
Login or Register to Ask a Question