Results 1 to 4 of 4

Thread: cron job help

  1. #1
    Join Date
    Oct 2008
    Location
    colachel
    Beans
    516
    Distro
    Ubuntu 13.10 Saucy Salamander

    cron job help

    Hi All

    I want to run the script on Tuesdays (On Dates Between 1-7 and 15-21) at 12:00 PM of every month.

    I have tried the below entry, but it is not working proper. Please help

    00 12 1-7,15-21 * TUE /root/script.sh

    Thanks in Advance
    Sahab

  2. #2
    Join Date
    Dec 2009
    Location
    germany
    Beans
    1,020
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: cron job help

    Quote Originally Posted by sahabcse View Post
    Hi All

    I want to run the script on Tuesdays (On Dates Between 1-7 and 15-21) at 12:00 PM of every month.

    I have tried the below entry, but it is not working proper. Please help

    00 12 1-7,15-21 * TUE /root/script.sh

    Thanks in Advance
    Sahab
    hi
    why you ain't let decide your script.sh to run or not to run e.g.:
    [ `date +%a` != "Tue" ] && exit 0
    echo "it's Tuesday - script will continued"
    cheers
    "What is the robbing of a bank compared to the FOUNDING of a bank?" Berthold Brecht

  3. #3
    Join Date
    Nov 2008
    Location
    Maine
    Beans
    1,125
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: cron job help

    cron can be tricky, unless youre deploying a script on multiple computers, I would look at something like this:
    https://apps.ubuntu.com/cat/applicat...nome-schedule/
    ~Conradin~

  4. #4
    Join Date
    Jul 2009
    Beans
    471
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: cron job help

    Take a look at "man 5 crontab", specifically the section mentioning
    Note: The day of a command's execution can be specified by two fields —
    day of month, and day of week. If both fields are restricted (i.e.,
    aren't *), the command will be run when either field matches the cur‐
    rent time. For example,
    ``30 4 1,15 * 5'' would cause a command to be run at 4:30 am on the 1st
    and 15th of each month, plus every Friday. One can, however, achieve
    the desired result by adding a test to the command (see the last exam‐
    ple in EXAMPLE CRON FILE below).
    # Run on every second Saturday of the month
    0 4 8-14 * * test $(date +%u) -eq 6 && echo "2nd Saturday"
    So you'd probably want something like
    0 12 1-7,15-21 * * [ $(date +%u) -eq 2 ] && /root/script.sh
    Mark your thread as [SOLVED], use Thread Tools on forum page.

Bookmarks

Posting Permissions

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