Timed Macro Not Running

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.

Is there some reason you do not just put the Mac to sleep, which will automatically require a sign-in when it is woke?

You can put to sleep via a KM Macro if you wish:

I have a fairly complex macro which does orderly close of all of my apps, and then puts the Mac to sleep.

Long story short: My Mac doesn’t auto-sleep because of VLC being paused (not stopped) in the BG. So I have a custom Keyboard Maestro macro that does some checking to see if everything else has been idle for X period of time, and IF yes, it uses the Put Computer to Sleep action you mentioned.

So this is really about Keyboard Maestro being able to continue doing that with the lock screen ON, which I plan on invoking manually.

But my first step was to reduce the action down to just the periodic check trigger + Put Computer to Sleep and it still didn't work. (Hence the question)

Does this make more sense?

It sounds like we're going the same direction but on different tracks :slight_smile:

Thanks!

6 posts were split to a new topic: How Do I prevent my Mac from sleeping while the KM macro is running

All,

I believe that I've got this issue resolved. In tinkering with an AppleScript (the basis of which I found on StackExchange) I found that when placed at the beginning of the macro it will successfully unlock the screen.

Note that you should run the macro manually a couple of times before relying on the script because you may have to give permission to a couple of services in the Security & Privacy Preferences pane to allow the script to control it. Replace the "YourPasswordHere" with the password that unlocks your screen/Mac:

image

This will unlock the Mac and allow you to proceed with the remainder of the automation as programmed into KM.