Arpit Shrotriya
Arpit Shrotriya

Reputation: 19

Is there any way to get email/whatsapp notification when a scheduled python file in task scheduler fails to execute?

I am currently working on scheduling some python tasks for different purposes, but I want to get notified about the failure of python code execution if it doesn't reach the end of line.

I have researched different solutions like, using management console to use event log handlers to trigger email notification, but this method is deprecated and only works if a program fails to start not if it fails to execute all the way. Further, Tried different python packages to get the desired result but no package shows the desired effect on file level.

So, I am looking for a way that notifies email/whatsapp based on failure of a scheduled task or failure of python file execution on File-level.

Upvotes: 1

Views: 266

Answers (1)

David Beauchemin
David Beauchemin

Reputation: 256

Disclaimer: promote my own library

I think the more straight forward approach would be to try/except catch and send an email using SMTP protocol in the except.

Other than that, I had similar concerns for long Python execution scripts that I wanted to get updates on. So for that, I've developed a package that allows a notificator to connect to various channel types (Slack, email, etc.) and could send an update notification. The more interesting part is that it proposes a decorator that could send a notification if an exception is raised. Feel free to use the code or the library.

Upvotes: 1

Related Questions