MacのWake/CRON

MacのWake/CRON

macOS Catalinaを実行している古いiMacがあります。 2つのCRONジョブが予約されています。 1 つは午前 (例: 午前 8 時)、もう 1 つは午後 (例: 午後 5 時) に実行されます。 CRONジョブは、いくつかのRスクリプトを実行するのに役立ちます。

マシンがスリープモードの場合、CRONジョブが実行されていないことを考えると、両方のジョブを実行させる最善の方法は何ですか? Macが午前中に「目覚め」、夕方に「終了」するようにスケジュールしましたが、完全にスリープ状態にならない限り、午後の作業は行われません。

私は2つの考えられる解決策を考えました。まず、異なる計画で異なるユーザープロファイルを設定します。ただし、コンピュータごとに1つの計画しかないため、この方法は機能しません。第二に、「昼寝」ですが、それもやり直すことができないようであるか、少なくとも一貫して実行できないようです。今は眠れないようにしたり、午後にマウスを動かして機械を目覚めさせるロボットを作る以外に、他の選択肢がありません。

より良いアイデアがありますか?

ありがとう、フィリップ

ベストアンサー1

Appleはこれを段階的に廃止する予定だったcron(しかし、長く続くので、最初に発表した時を忘れてしまった:-)).ただし、launchdこれを使用すると問題を簡単に解決できます。

からman launchd.plist

StartCalendarInterval <dictionary of integers or array of dictionaries of integers>

This optional key causes the job to be started every calendar interval as specified. 
Missing arguments are considered to be wildcard. The semantics are similar to crontab(5)
in how firing dates are specified. Multiple dictionaries may be specified in an array
to schedule multiple calendar intervals.

Unlike cron which skips job invocations when the computer is asleep, launchd will start
the job the next time the computer wakes up.  If multiple intervals transpire before the
computer is woken, those events will be coalesced into one event upon wake from sleep.

この回答StackOverflowには、launchd.plist単純なcronjobのための基本的なテンプレートがあります。

おすすめ記事