Time limit → 5 hours
Longest run → 12.6 hours, Mac asleep on battery for 12.4
Log said → exit 0 every night, even when the limit fired
Our nightly AI job has a five hour time limit. Twice in its first week, it ran for more than eleven hours. The limit wasn't broken. It was never tested the way the job really runs, and the log that should have told us was printing the wrong thing every night.
If you run anything on a schedule, a backup, a report, an AI task that works while you sleep, this is the check worth doing once.
The limit is one line
Every night at 9 pm a small script on a Mac in the office starts our AI job. The AI builds a blog post and a short video, then writes a report. A stuck job shouldn't run into the next morning, so the script has a ceiling:

"alarm 18000" means: after 18,000 seconds, five hours, send a stop signal. Simple, and on some nights it did exactly that.
Seven nights in the log
The script writes a start line and an end line for each night. Here are the first seven nights, November 23 to 29, 2026:

Two nights stopped at 2:00 am on the dot. That's 9 pm plus five hours, so the limit fired. Three nights finished early on their own. And two nights ran long: 11.3 hours on November 25 and 12.6 hours on November 28.
The line works
My first guess was that the AI program was ignoring the stop signal. So I tested it with the same line and a three second limit:

It stopped in 3.31 seconds, with exit code 142, which is the code for a stop by that signal. The line works. Something else was different on the two long nights.
The power log showed why
Macs keep a power log of every sleep and wake. I pulled it for the hours of each run and added up the time awake and the time asleep.

On the two nights the limit fired, the Mac was awake for all five hours. On the two long nights, it was asleep for 11.0 and 12.4 hours. The power log says why: the lid had been closed since the early evening and it was on battery.

A closed laptop on battery naps, wakes for a few seconds for network and upkeep tasks, and naps again. That night it did that 85 times during the run. Our job started in one of those short wakes and crawled along in the gaps.
The logs point to one explanation. The timer in that line counts time the computer is awake. By its clock, the November 28 run lasted about 11 minutes, so it never reached five hours. The job finished on its own late the next morning.
The log was wrong too
Here's the part that hid it. Every line in that log says "exit 0," which normally means the job finished cleanly. That includes the two nights the limit stopped it at 2:00 am, which should say 142.

The log line printed the date first and the exit code second, and printing the date reset the code to zero. Save the code first and the same test shows 142. So the log could never show a stop, even when one happened.
That's the same lesson as the automation that failed quietly: a status line is only as good as what it actually checks.
What I'm changing
- Save the real exit code straight after the job ends, before anything else runs.
- Keep the Mac awake while the job runs, or use a limit that checks the clock time instead of a timer.
- Put the start time, end time and how it ended in the nightly report I read, not just in a log file.
As of this post, these are written up and waiting for me to apply them. I didn't want to change the script while the job that runs it was in the middle of a night's work.
How to test your own time limit
- Write down the limit for each scheduled job and what should happen when it's reached.
- Test it on purpose with a limit of a few seconds. Time it. It should stop at the limit.
- Test it the way the job really runs. Same computer, same schedule, same power settings. A laptop with the lid closed is a different test from one plugged in on a desk.
- Check what's left running. In my test, stopping a script left the program it had started still running.
- Check that the log saves the real exit code. Stop a job on purpose and read the log line.
- Once a month, compare end times to the limit. A run far past the limit means it didn't fire.
A limit you've never seen fire is a guess.
What this doesn't show
Seven nights, one Mac, one way of setting a limit. The claim that the timer only counts awake time is what the logs show, not something I tested by putting the Mac to sleep on purpose. Other computers and other ways of setting a limit can behave differently, which is the reason to test your own.
This kind of thing is what a weekly mistake log is for. The November 28 report said the limit hadn't stopped that run. Lining up all seven nights is what showed the pattern.
Get the SOPs
SOP 19 in my free pack is this test, step by step. Read it on the example AI SOPs page or download the PDF from there.
Sources and local evidence
- The start script and its log: our nightly job, November 23 to 29, 2026.
- The three second tests and the exit code test: run November 30, 2026, output saved.
- Awake and asleep time: the Mac's own power log for each run, added up by a short script on November 30, 2026.
Related
- Our automation stopped backing up for three days. Nothing told us.
- Write down every AI mistake for a week
- Check your AI voice against the script
Read next: Check your AI voice against the script. A flag means listen, not redo.