applescript – Execute missed launchd job upon subsequent startup

[ad_1]

I wish to make periodic backups utilizing rsnapshot on my MacBook. Nonetheless, as it’s a laptop computer, it should solely be powered on at random occasions. Thus, scheduled duties is perhaps missed whereas it’s powered off. An answer for this may be anacron which doesn’t appear to be accessible on macOS although. Apparently macOS’ native launchd service shouldn’t be able to scheduling jobs within the method of anacron. Right here it says:

When you schedule a launchd job by setting the StartCalendarInterval key
and the pc is asleep when the job ought to have run, your job will
run when the pc wakes up. Nonetheless, if the machine is off when
the job ought to have run, the job doesn’t execute till the subsequent
designated time happens. All different launchd jobs are skipped when the
laptop is turned off or asleep; they won’t run till the subsequent
designated time happens.

If my month-to-month rsnapshot backup is, for instance, scheduled for the primary day of each month however the laptop computer is powered off that day, that might imply I lack that backup and solely get the subsequent one an entire month later.

Is there any workaround to this? Maybe linking the launchd schedule with some conditional instructions in a bash script?

The one concept I needed to resolve this was to schedule the launchd job for each single day at a particular time and execute a script which:

  1. Checks a timestamp log file if a profitable backup has run this month
  2. If sure –> exit, if no –> run backup
  3. If backup profitable –> add timestamp to that file

Although that appears unnecessarily complicated compared to anacron jobs which you could create on Unix techniques.

[ad_2]

Leave a Reply

Your email address will not be published. Required fields are marked *