How Can Python Handle systemctl stop?

后端 未结 1 1274
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-18 06:07

I have a Python script that is running as a service. It writes to disk. If a user calls systemctl stop on the service, I would like to handle the command in my own way to re

相关标签:
1条回答
  • 2021-01-18 07:00

    As described in systemd documentation, processes will receive SIGTERM and then, immediately, SIGHUP. After some time, SIGKILL will be send.

    All signals, as well as strategy of sending them, can be changed in relevant service file.

    See another stackoverflow question to see how handle these signals in your Python program.

    0 讨论(0)
提交回复
热议问题