CRON does not trigger at night: how to determine if there is an active pmset command which I created and forgot about?

KM 11.0.3, Ventura latest update
I can't figure out why my CRON triggers between 2 and 5 am are not working.
When I look at KM log, nothing happens at the time of the cron trigger which does not trigger.
I wonder if I previously used pmset commands to put my mac to sleep and wake, and I forgot about them.

Is there a way to determine if I previously create pmset commands in terminal mode?

My intention is to trigger a "wake" command just before running the macro with the CRON trigger

thanks in advance for your time and help

In Terminal, pmset -g sched should show scheduled events.

Is System Settings->Energy Saver "Prevent automatic sleeping..." turned on? No triggers will fire when your Mac is asleep, so you'll either have to make sure it never sleeps or do something like a pmset to wake it at 2am followed by caffeinate -s -t 10800 to keep it awake until 5.

1 Like

I think that it's precisely the problem if I understand correctly. One of the ventura updates removed the prevent automatic sleeping option which somehow messed up my mac and causes cron triggers not to function at night. I can't understand how it is that you still have it.

I will look up pmset and cafferinate.

Would you happen to know if it's possible give my pmset caffeinate command and tell my mac to send a notification every time it triggers (which would be daily). I really don't like making changes in terminal and forgetting about them.

thanks very much !!

Screenshot (click to expand/collapse)

me again !

May I ask how you would interpret the following ?

When the Prevent automatic sleeping button was present, it was turned to OFF. I am sure of that. I wonder if the Ventura update removed the button and turned the automatic sleep button to ON.

thanks very much

P.S. I wonder if there would be a way to simply turn automatic sleeping off with a terminal command, instead of the daily wake and caffeinate ?

If it's a laptop, try System Settings->Displays->Advanced -- you should find "Prevent automatic sleeping on power adapter...".

I do wish they wouldn't move this around all the time!

sleep        0

Usually means you have set your system to not sleep (just as you want) although, again, I'm not certain that's consistent across system versions...

So it looks like you've got everything set up the way you want at the System Settings level. Are you sure you haven't got a cron or idle triggered macro that's putting your Mac to sleep for you?

1 Like

Finally, I found it and it's set to off

I will check once again. Thanks a million !!

are the 2 items below problematic and contrary to the prevent automatic sleeping on ?
thank you

"Sleep On Power Button" does what it says -- lets you put the machine to sleep by pressing the power button. Power Nap is what lets your Mac cloud sync and so on when it is asleep.

Check the output of pmset -g log to see a (long!) list of sleep, wake, and other events. Also the Mac Analytics log in Console -- filter on powerd for starters.

If you are using a laptop -- you used to be able to turn off "clamshell" sleep so it didn't sleep when you closed the lid. I don't think you can now, and your Mac will only stay awake if it is plugged into a display and the display is turned on. The laptop users here may be able to comment on that.

I'm sorry: I misled you. It is not the Prevent Automatic Sleeping button which has disappeared, it is the Energy Saver schedule, to make sure that I was not putting my Mac Studio M1 to sleep by accident.

in man caffeinate

Examples
Prevent sleep indefinitely (until the terminal session is closed):
$ caffeinate

That's a different example to my man page. But note the "until terminal session is closed" -- how are you going to run the command? What does that mean with respect to the session closing?

Which is why you might prefer an assertion for a time period, like caffeinate -s -t 10800. You should be able to:

  1. Have pmset wake your Mac at 2am
  2. Have KM run a cron-triggered macro containing an "Execute a shell script -- caffeinate -s -t 10800" action (the -t is "assert for the following number of seconds")
  3. Do any other cron-triggered macros you want until 5am
  4. A little after 5am you computer will go back to sleep
1 Like

thanks very much !