L
L
L0re2020-07-11 09:06:11
Python
L0re, 2020-07-11 09:06:11

How to execute code on process termination with script?

I need to execute code when the computer is turned off.
Tried atexit.register, but it only works with ctrl + c. On emergency termination (by clicking on the cross or in the task manager), the code is not executed

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
ScriptKiddo, 2020-07-11
@ScriptKiddo

At emergency termination (by clicking on the cross or in the task manager), the code is not executed.

Wrap your script in a service and keep track of its status with the second script. When you stop - perform the necessary actions with the second script
https://stackoverflow.com/questions/32404/how-do-y...
https://github.com/torfsen/python-systemd-tutorial

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question