Timed Macro Not Running

I'm trying to run backups at a set time. These won't run no matter what I do, so I'm hoping for some advice to either A) get this macro to run at a late hour, or B) set it to run around 6 PM but with a prompt to wait for execution if I'm still working on the computer.

Option A: The Energy Save preferences are set to Prevent Computer From Sleeping and to Wake for Network Access. The computer stays on all night.

Even executing the macro from Calendar fails.

The individual macros called in this DO work when manually executed, and this macro works entirely when run while I'm actively using the computer.

Option B: I'd like to popup a prompt that asks if I"m ready to run the backups. If I click a No or Wait button, I want the macro to ask again in 30 minutes. If I click Yes or fail to click anything after 5 minutes, the macro runs the backups.

I haven't been able to figure out how to make such a prompt.

Option C: Got an alternate method of making this damned thing work?

Thanks in advance for any help.

So, the main question seems to be: what is the difference between the computer staying on during the night and the computer being actively used?

Have you set it maybe to “Require password … after … screen saver begins”?

(System Preferences > Security & Privacy > General)

Nope.

I've tried setting it to wake at a certain hour, but that doesn't work either. I cleared both options.

Here's my Energy Saver prefs.

Stupid question, but have you verified that the computer is awake at 00:25h?

Another possible reason:

Maybe your macro is in an app-specific macro group (instead of the Global Macro Group).

I know, you have said it works when actively using the computer, but perhaps – while actively using the computer – you were, by chance, working in the app where the macro group is active.

The computer should ALWAYS be awake with the above settings.

Nope. All Applications, All Windows, Always Activated.

According to your settings, it should, yes. But, since you are saying the macro triggers while the computer is actively used, there is a suspicion that it is not awake; or somehow not as awake as when actively used…

  • Something wrong with the Energy Saver panel; corrupted preferences plist file?
  • Any other processes that put the computer to sleep? (For example some of my CarbonCopyCloner schedules are set to put the computer to sleep when finished.)
  • Have you tried it without the “Put hard disks to sleep” option? With “Turn display off: Never”?
  • If you have another Mac, does the macro trigger there?

You can check whether the macro triggers at all by looking in the Engine.log file the next morning.

If the Mac is asleep, nothing will happen, no macros will fire.

If the Mac is awake, the macro should fire, however if the screen is asleep, screen saving or screen locked, many facilities will be blocked by the system. Things like Execute Script should be fine, but things that try to do UI will fail.

You might like to do something like this:

Trigger at 6pm
Pause Until IDLE() > 60*5 (less than your display sleep time)
Alert “Run Macro?” Timeout 1 minute without aborting the macro
Do stuff

Of course, if you cancel the macro, then the actions will not run at all.

Uncheck “Put hard disks to sleep when possible.” Then give it a shot.

Also are you closing all apps when you are done? Or do they remain open?

You might want to put an action to close all open apps before running the remaining actions. Or just quit them before you go home.

I’ll give that a try, Peter. Thanks.

In the meantime, my engine log shows the following reasons for cancelling the macro.

2017-03-03 00:30:00 Execute macro ‘00:30 Nightly Operations’ from trigger At 0:30 every day
2017-03-03 00:30:53 Action timeout exceeded. Macro ‘00:30 Nightly Operations’ cancelled (while executing Activate Google Chrome).
2017-03-04 00:30:00 Execute macro ‘00:30 Nightly Operations’ from trigger At 0:30 every day
2017-03-04 00:30:31 Action timeout exceeded. Macro ‘00:30 Nightly Operations’ cancelled (while executing Activate Google Chrome).
2017-03-05 00:30:00 Execute macro ‘00:30 Nightly Operations’ from trigger At 0:30 every day
2017-03-05 00:30:50 Action timeout exceeded. Macro ‘00:30 Nightly Operations’ cancelled (while executing Activate Finder).
2017-03-06 00:30:00 Execute macro ‘00:30 Nightly Operations’ from trigger At 0:30 every day
2017-03-06 00:30:50 Action timeout exceeded. Macro ‘00:30 Nightly Operations’ cancelled (while executing Activate Finder).

Some notes:

  • Chrome was running and open every time Activate Google Chrome failed.
  • On 2017-03-04, before the 03-05 actions, I tried changing the order to run the orange macros before the yellow ones.

Trying tonight with "Put hard disks to sleep when possible" disabled.

Also are you closing all apps when you are done? Or do they remain open?

Open.

You might want to put an action to close all open apps before running the remaining actions. Or just quit them before you go home.

I frequently leave apps open that I'll need in the morning.

If the screen is sleeping, locked, or screen saving, then you will not be able to activate an application, or do other UI tasks.

You will need to stop the screen saver first using the Stop Screen Saver action. If it is locked or sleeping, that may not be sufficient.

You may need to allow some time for the screen saver to stop.

I don’t use a screen saver; it’s disabled.

But you have verified that the Mac is awake at the point when the script is about to trigger, right? (And that the screen is unlocked, etc.)

How can I verify that?

As I said, it triggers when I’m looking at the screen, but it’s supposed to happen in the middle of the night when I’m not around to watch.

The Engine logs show that it seems to be firing.

No difference with “Put hard disks to sleep when possible” disabled.

Log:
2017-03-07 00:30:00 Execute macro ‘00:30 Nightly Operations’ from trigger At 0:30 every day
2017-03-07 00:30:50 Action timeout exceeded. Macro ‘00:30 Nightly Operations’ cancelled (while executing Activate Finder).

Trying Peter’s Pause Until IDLE, though that won’t help on days and evenings when I haven’t used the computer.

Set it for a time first thing in the morning, immediately after you would normally start using your Mac. And observe your Mac at that point.

If the screen is asleep, screen saving, screen locked, then you will need to deal with that.

It runs when I’m using my Mac. It tries to run but fails on pretty much any program activation when I’m not using my Mac.

Apple Support says contact you. :disappointed:

I’ve gotten half of this to work–reliably for a week now.

Peter mentioned that KM can’t do gui-related actions when the screen is sleeping. Once I disabled any actions that relied on whether Finder had this window name open, the folder sync macros worked. The Chrome and Session Buddy backup macros won’t because they rely on KM “seeing” the screen.

I’m not sure how I’ll get the latter to work, but the daily sync/backups of drives were the most important. Thank you for all the help, everyone.

I’m interested in having the computer Sleep while the screen is locked. But it doesn’t work.

“Sleep Computer” doesn’t seem like a UI interaction, but maybe it is.

I setup a simple Periodically when logged in macro to fire every 10s, and all it does is run the Sleep Computer macro. I lock the screen and the computer doesn’t sleep.

I also tried Wake Screen just before. It does wake the screen, but doesn’t go to sleep UNTIL the lock is disabled. Then it goes to sleep immediately.

  • Is this expected?
  • Is there any way around this?
  • Maybe using a shell script or AppleScript to initiate sleep?

Thanks.