launchd
これを行うための適切な方法です(crontab
Macでは非推奨になりましたlaunchd
)。プログラムに関する情報(実行可能ファイルの名前、引数など)を含むplistファイルを作成すると、その一部は(ブラウザーに入力され、テストされていない警告)になります。
<key>StartCalendarInterval</key>
<dictionary>
<key>Hour</key>
<integer>12</integer>
</dictionary>
<key>StartInterval</key>
<integer>7200</integer>
<key>LimitLoadToSessionType</key>
<string>Aqua</string>
<key>RunAtLoad</key>
<true/>
- は
StartCalendarInterval
、12時間目(正午)にプログラムを実行する必要があります。
- は
StartInterval
2時間(= 7200秒)ごとにプログラムを実行する必要があります
- Aquaセッションの
LimitLoadToSessionType
開始時にのみプログラムをロードします(ユーザーは実際にウィンドウサーバーにログインします(したがって、ユーザーがログインしている場合はロードできなくなりますssh
)
- は
RunAtLoad
、plistがロードされたときに実行するように実行可能ファイルに指示します。これを、と組み合わせるとLimitLoadToSessionType
、ユーザーがログインしたときに実行可能ファイルが起動するはずです。
StartInterval
とStartCalendarInterval
は相互に排他的である可能性があります。その場合は、StartInterval
キーを取り出して次のように変更できますStartCalendarInterval
。
<key>StartCalendarInterval</key>
<array>
<dictionary>
<key>Hour</key>
<integer>0</integer>
</dictionary>
<dictionary>
<key>Hour</key>
<integer>2</integer>
</dictionary>
<dictionary>
<key>Hour</key>
<integer>4</integer>
</dictionary>
<dictionary>
<key>Hour</key>
<integer>6</integer>
</dictionary>
...
<dictionary>
<key>Hour</key>
<integer>12</integer>
</dictionary>
...
<dictionary>
<key>Hour</key>
<integer>22</integer>
</dictionary>
</array>
詳細については、を参照してくださいman launchd.plist
。