DBAsupport.com Forums - Powered by vBulletin
Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: help with cron job scheduling

  1. #1
    Join Date
    Sep 2001
    Posts
    200
    Hi guys,
    I wish to schedule a job to run
    once every 3 days . I want to enter something like this
    0 0 1-3 * *

    another once every week like

    0 0 1-6 * *

    Does this look right?

    Thanks for your help
    Life is what is happening today while you were planning tomorrow.

  2. #2
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    Originally posted by ndisang

    0 0 1-3 * *
    This will run your job on the 1st, 2nd, and 3rd of every month at midnight.


    0 0 1-6 * *

    This will run your job on the 1st through the 6th of every month at midnight.

    The fields, in order are:
    minutes (0-59)
    hour (0-23)
    day of month (1-31)
    month of year (1-12)
    day of week (0-6, 0=sunday)

    man crontab for details
    Jeff Hunter

  3. #3
    Join Date
    Oct 2000
    Location
    Saskatoon, SK, Canada
    Posts
    3,925
    Cronjob once every three days, starting on Sunday
    Code:
       Runs exactly at midnight
       0 0 * * 0,3,5 
    
       Runs anytime at midnight depending on the schedulability
    
       * 0 * * 0,3,5

    Cronjob once a week, executed on Friday Mid-night
    Code:
        0 0 * * 6

    Sam
    Thanx
    Sam



    Life is a journey, not a destination!


  4. #4
    Join Date
    Feb 2001
    Posts
    41
    Hi Jeff & Sam,

    I have another question. One of our customer wants to run a job every month on first Sunday. How I can schedule crontjob for this.

    Thanks,

    Farrukh

  5. #5
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    You can't. You have to schedule the job to run either on sunday or the first 7 days of the month. At the very start of your script you have to check the other condition and exit if it's not true.

    I know, it sucks and it doesn't work the way you think it should.
    Jeff Hunter

  6. #6
    Join Date
    Oct 2000
    Location
    Saskatoon, SK, Canada
    Posts
    3,925
    Code:
      0 0 1-7 * 0
    
      This will execute the job on the first sunday only.
    Sam
    Thanx
    Sam



    Life is a journey, not a destination!


  7. #7
    Join Date
    Feb 2001
    Posts
    41
    Thank you very much Jeff & Sam for you quick response. I feel more confident now to explain this to the customer.

    Cheers!

    Farrukh

  8. #8
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    Originally posted by sambavan
    Code:
      0 0 1-7 * 0
    
      This will execute the job on the first sunday only.
    Sam
    Nope, not on Solaris anyway. This will execute on days 1-7 AND every sunday.
    Jeff Hunter

  9. #9
    Join Date
    Oct 2000
    Location
    Saskatoon, SK, Canada
    Posts
    3,925
    Yep! you are correct. But there has to be some way to do it

    Sam
    Thanx
    Sam



    Life is a journey, not a destination!


  10. #10
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092

    From the man page ( http://docs.sun.com/ab2/coll.475.1/T...Enc=iso-8859-1 ):

    minute (0-59),
    hour (0-23),
    day of the month (1-31),
    month of the year (1-12),
    day of the week (0-6 with 0=Sunday).

    Each of these patterns may be either an asterisk (meaning all legal values) or a list of elements separated by commas. An element is either a number or two numbers separated by a minus sign (meaning an inclusive range). Note that the specification of days may be made by two fields (day of the month and day of the week). Both are adhered to if specified as a list of elements.
    Jeff Hunter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width