JOKER
JOKER

Reputation: 35

Terminate a running python program only when the system shuts down

Is there anyway to terminate a python program only when the user shutsdown the system? I want to include the condition in the while loop so that it keeps on looping till the system shutsdown. Also is there a way to start the program automatically on booting the system?

Upvotes: 0

Views: 74

Answers (2)

Tuan Vo
Tuan Vo

Reputation: 2085

Convert your python app to linux service is much better than white true only

Upvotes: 2

lenik
lenik

Reputation: 23546

This works for me:

while True :
    pass  # do something

This loop will be terminated when the system shuts down.

Upvotes: 2

Related Questions