Crontab conundrum - Unix

This is a discussion on Crontab conundrum - Unix ; I'd like to schedule a job that runs: - every two minutes during the workday (7am-7pm, M-F) - every hour at all other times (nights, weekends) I came up with the following set of three crontab entries, but I have ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Crontab conundrum

  1. Crontab conundrum

    I'd like to schedule a job that runs:

    - every two minutes during the workday (7am-7pm, M-F)
    - every hour at all other times (nights, weekends)

    I came up with the following set of three crontab entries, but I have
    to believe there's a shorter or at least more elegant way to do this.

    */2 7-19 * * mon-fri root /scripts/myscript
    01 0-7,19-23 * * mon-fri root /scripts/myscript
    01 * * * sat-sun root /scripts/myscript


    Feel free to further my education... thanks.

    -tsg-

  2. Re: Crontab conundrum

    In article
    ,
    ThatSeattleguy wrote:

    > I'd like to schedule a job that runs:
    >
    > - every two minutes during the workday (7am-7pm, M-F)
    > - every hour at all other times (nights, weekends)
    >
    > I came up with the following set of three crontab entries, but I have
    > to believe there's a shorter or at least more elegant way to do this.
    >
    > */2 7-19 * * mon-fri root /scripts/myscript
    > 01 0-7,19-23 * * mon-fri root /scripts/myscript
    > 01 * * * sat-sun root /scripts/myscript
    >
    >
    > Feel free to further my education... thanks.
    >
    > -tsg-


    That seems to be the best approach. The varying granularity of your
    time requirements precludes running myscript with scheduling smarts
    built in. I'd also put logic in the script to ensure it's not run
    multiple times during the day by checking that it's not already running
    somehow (e.g. myscript creates a lock file when it starts and deletes it
    when it exits and exits if the lock file exists when it starts).

    --
    DeeDee, don't press that button! DeeDee! NO! Dee...
    [I filter all Goggle Groups posts, so any reply may be automatically by ignored]



+ Reply to Thread