Exit code 0 is a lie: 7 ways my unattended automation silently did nothing
I run about thirty scheduled jobs on a single Windows box. Some are scrapers, some generate content, some are trading bots, some just check that the other jobs are alive. Most of them were written and are maintained by an AI coding agent that I let run unattended. Over three months, every one of the failures below reported success . The scheduler said LastTaskResult = 0 . The logs looked fine or…
Reports of exit code 0 being a reliable indicator of success are false. In a three-month period, an unattended automation system reported success for every failure. The scheduler showed LastTaskResult = 0, but the logs either didn't exist or looked fine. Nothing actually happened.
Seven ways the system failed to deliver results:
1. A wrapper that always returns 0. Using a VBScript launcher to hide console windows caused the exit code to always be 0, regardless of the actual result. Fix by calling Run as a function and passing the value out.
2. A .cmd shim overwriting the exit code. An echo statement that always succeeded caused the batch file to return 0 even if the underlying command failed. Debugging tip: when you fix one layer and still get false greens, assume there's another layer.
3. Running a Flask service as a Windows service without a console. The script encoded the output, but sys.stdout wasn't usable with pythonw.exe. The service failed silently because there was no console to print the traceback. Fix by using regular python.exe with output redirected to a file.
4. Scheduler defaults that kill laptop jobs. DisallowStartIfOnBatteries and StopIfGoingOnBatteries defaults prevented jobs from running on a laptop. StopOnIdleEnd would terminate the job when the machine entered idle state. Adjust the settings to allow the job to continue running.
5. A comment warning about a trap became the trap. A Chinese comment in a batch file, due to command decoding differences, caused a function call to execute unexpectedly, even though the underlying command succeeded. Always be cautious about comments and their encoding.
The main takeaway: stop relying on exit codes and start checking artifacts. Verify the actual results, not just the exit code.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.