Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2005
    Posts
    102

    Unanswered: biweekly schedule through cron

    Hi All,

    This is the first time I am posting on this forum.

    I want to schedule my DB2 reorgchk every other sunday through cron.

    I did the following:

    PHP Code:
    # Bi-Weekly REORGCHK for db2 databases.
    00 06 1-7,15-21 * * [ "$\(date +\%a\)" == "Sun" ] && /usr/local/db2/online_reorgchk.sh 2>&
    for some reason it runs just the first sunday that falls between 1-7 and does not run on the sunday that falls between 15-21.

    Am I doing it right? Is there a better way to schedule a script every other sunday?

    Thanks for the help

    Anks

  2. #2
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    Quote Originally Posted by anksagr
    Code:
    # Bi-Weekly REORGCHK for db2 databases.
    00 06 1-7,15-21 * * ...
    for some reason it runs just the first sunday that falls between 1-7 and does not run on the sunday that falls between 15-21.
    This would run your command every day from the 1st thru 7th and 15th thru 21st of each month (at 6:00). So your statement saying that it just rons on the first Sunday is not true. The following should do the restriction for the Sunday as well:
    Code:
    00 06 1-7,15-21 * 7 ...
    The crontab specifications for the weeks are fine. If it doesn't work, maybe your cron doesn't support this format? If so, you could split this up into multiple crontab entries.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  3. #3
    Join Date
    Feb 2004
    Location
    Los Angeles, CA
    Posts
    28

    Try this

    anksagr

    Try this, it worked on my server.

    Code:
    00 06 1-7,15-21 * * test `date +\%a` = Sun && /usr/local/db2/online_reorgchk
    Good Luck

  4. #4
    Join Date
    Mar 2008
    Location
    Tacoma, WA
    Posts
    11
    Quote Originally Posted by Bob4480
    anksagr

    Try this, it worked on my server.

    Code:
    00 06 1-7,15-21 * * test `date +\%a` = Sun && /usr/local/db2/online_reorgchk
    Good Luck
    Code:
    00 06 1-7,15-21 * Sun /usr/local/db2/online_reorgch
    Will do the same thing since the last * was for Day of Week. `man 5 crontab` gives the exact details...

    Prevents the system from starting a shell command to check that it is sunday and continue if it is...

  5. #5
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    Quote Originally Posted by Bob4480
    anksagr

    Try this, it worked on my server.

    Code:
    00 06 1-7,15-21 * * test `date +\%a` = Sun && /usr/local/db2/online_reorgchk
    Good Luck
    Why so complicated? Just use the infrastructure that cron provides.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

Posting Permissions

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