Skip to main content
I blew it! This answer would run the script each minute, ad infinitum. That's not what the OP asked. She wanted every minute during 21:00. So, this is a massive do-over!
Source Link
Seamus
  • 5.1k
  • 3
  • 23
  • 44

To getEdit start

You got it all correct except for enclosing your <dict> element inside an <array> element. Your script towill run every minute requiresfrom 21:00 to 21:59 with the following as your syntaxStartCalendarInterval key (for example):

    <key>StartCalendarInterval</key>
    <array>
        <dict>
            <key>Minute<<key>Hour</key>
            <integer>0<<integer>21</integer>
        </dict>
        <dict></array>
        

If you wanted your script to run every minute, every hour, every day, every year, the following would be the correct (but certainly not obvious) syntax for that:

    <key>Minute<<key>StartCalendarInterval</key>
    <array>
        <integer>1<<dict/integer>>
        </dict>array>
        <dict>
            <key>Minute</key>
      

My original answer (below) would also work, but it's clearly much more tedious! OTOH, if one needed every other minute, or certain minutes, it might be useful.

Edit end


``` StartCalendarInterval Minute 0 Minute 1 Minute 2 Minute 3 Minute 4
   ... ad nauseum <integer>2</integer>...
        </dict>
        <dict>
            <key>Minute</key>
            <integer>3<<integer>59</integer>
        </dict>
        <dict>
            <key>Minute<</key>array>
       

To answer your question, *"Why <integer>4</integer>
is this not running every minute?"*, it's only </dict>

because you failed to enclose `<dict>` inside ..`<array>`. ad nauseum ...

 FWIW, it seems very odd to me <dict>
also, and ***WHY*** it's designed this way is an answer I'd like <key>Minute</key>
to hear myself. But then I guess Apple could use the defense <integer>59</integer>
that "just because the *semantics* are similar does </dict>

not mean the syntax </array>is."

To answer your question, "Why is this not running every minute?", I would have to say that your assumption was incorrect :) FWIW, it seems very odd to me also, but this is how I got it to work, so another answer might be that's the way Apple designed it? Why it's designed this way is an answer I'd like to hear myself, but I guess Apple could use the defense that "just because the semantics are similar does not mean the syntax is."

To get your script to run every minute requires the following syntax (for example):

<key>StartCalendarInterval</key>
    <array>
        <dict>
            <key>Minute</key>
            <integer>0</integer>
        </dict>
        <dict>
            <key>Minute</key>
            <integer>1</integer>
        </dict>
        <dict>
            <key>Minute</key>
            <integer>2</integer>
        </dict>
        <dict>
            <key>Minute</key>
            <integer>3</integer>
        </dict>
        <dict>
            <key>Minute</key>
            <integer>4</integer>
        </dict>

       ... ad nauseum ...

        <dict>
            <key>Minute</key>
            <integer>59</integer>
        </dict>

    </array>

To answer your question, "Why is this not running every minute?", I would have to say that your assumption was incorrect :) FWIW, it seems very odd to me also, but this is how I got it to work, so another answer might be that's the way Apple designed it? Why it's designed this way is an answer I'd like to hear myself, but I guess Apple could use the defense that "just because the semantics are similar does not mean the syntax is."

Edit start

You got it all correct except for enclosing your <dict> element inside an <array> element. Your script will run every minute from 21:00 to 21:59 with the following as your StartCalendarInterval key :

    <key>StartCalendarInterval</key>
    <array>
        <dict>
            <key>Hour</key>
            <integer>21</integer>
        </dict>
    </array>

If you wanted your script to run every minute, every hour, every day, every year, the following would be the correct (but certainly not obvious) syntax for that:

    <key>StartCalendarInterval</key>
    <array>
        <dict/>
    </array>

My original answer (below) would also work, but it's clearly much more tedious! OTOH, if one needed every other minute, or certain minutes, it might be useful.

Edit end


``` StartCalendarInterval Minute 0 Minute 1 Minute 2 Minute 3 Minute 4
   ... ad nauseum ...

    <dict>
        <key>Minute</key>
        <integer>59</integer>
    </dict>

</array>

To answer your question, *"Why is this not running every minute?"*, it's only because you failed to enclose `<dict>` inside `<array>`.  FWIW, it seems very odd to me also, and ***WHY*** it's designed this way is an answer I'd like to hear myself. But then I guess Apple could use the defense that "just because the *semantics* are similar does not mean the syntax is."
Source Link
Seamus
  • 5.1k
  • 3
  • 23
  • 44

To get your script to run every minute requires the following syntax (for example):

<key>StartCalendarInterval</key>
    <array>
        <dict>
            <key>Minute</key>
            <integer>0</integer>
        </dict>
        <dict>
            <key>Minute</key>
            <integer>1</integer>
        </dict>
        <dict>
            <key>Minute</key>
            <integer>2</integer>
        </dict>
        <dict>
            <key>Minute</key>
            <integer>3</integer>
        </dict>
        <dict>
            <key>Minute</key>
            <integer>4</integer>
        </dict>

       ... ad nauseum ...

        <dict>
            <key>Minute</key>
            <integer>59</integer>
        </dict>

    </array>

To answer your question, "Why is this not running every minute?", I would have to say that your assumption was incorrect :) FWIW, it seems very odd to me also, but this is how I got it to work, so another answer might be that's the way Apple designed it? Why it's designed this way is an answer I'd like to hear myself, but I guess Apple could use the defense that "just because the semantics are similar does not mean the syntax is."