L
L
L0re2020-07-11 19:47:32
Python
L0re, 2020-07-11 19:47:32

How to send a message to the mail when the PC is turned off?

I need to send a message to the mail when the PC is turned off.
I know how to send a message, but I don’t know how to track a PC shutdown

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vlad, 2020-07-11
@vchpro

import atexit

def exit_handler():
    print("Do something on shutdown")

atexit.register(exit_handler)

Will not work with a "hard" (power off) shutdown
Source

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question