I have a Python script with a function I want to execute every X minutes.
from threading import Timer x = 5 def control(): Timer(x*60, control).start() rest_of_the_function() control()
When I run the script in its Python virtual environment from the terminal, there is no problem; when I run it as systemd service, it calls
control() function just once and then it doesn't do anything else.
If I check the service through
systemctl status myservice its Active field says active (running). There are no errors in the log.
The content of the /lib/systemd/system/myservice.service file is the following.
[Unit] Description=Short description [Service] Type=simple WorkingDirectory=/home/user/myservice ExecStart=/home/user/myservice/myvenv/bin/python main.py [Install] WantedBy=multi-user.target
Why does it just call
control() once? Can I fix it?