I find the Microsoft Task Scheduler useful for running scripts on Microsoft. It’s Microsoft’s “cron”. I’ve used it for multiple projects, but there’s something you should be fully aware of… scripts may give a failure code of 0x1 and the scheduler will mark the task as successful.
This happened to me before. I decided to check on my task to see how it had be running and wanted to see about any hiccups. Here the program had been failing for a decent period of time. I thought the trigger event I set in scheduler would have altered me via email, but it never sent the email! Why would this happen?
After some searching I see that some parameters can determine this outcome. For instance this can happen if “Run with highest privileges” is not selected. Others reported that it would only work properly if they selected “Run only when user is logged on”. Task scheduler does this to Python programs that fail. Even if they fail miserably!
Ironically, my little test gave the proper exit codes. I had more challenges when I first ran into this. My point is that small changes in the task scheduler settings can radically change the outcome and it’s not easy to narrow down the cause.
Set a backup notification! Task Scheduler doesn’t seem to have a very robust way to set conditions for notification. You could track down an event id from Event Viewer and then set another task to watch for that event id to pop up and then email you. However, that’s kind of a pain and it’s a confusing mess with which id could be generated as well as trying to be proactive about the problem. Take a look at my first post about calling a PowerShell script to send an email. You could send a text via Twilio. Make a little notification module that you can tack on to your Python programs. Get creative, test out some solutions, and share your experience with me!