My script to record all played steemmonster games from https://beempy.com froze:
I restarted the script (I’m using systemctl for this) and it is now catching up.
There was no bug, it just froze. This happend already before and I will now try to fix this.
I’m thinking of restarting the systemctl service every day. By this, a frozen script can only lead to a maximum stop of 24 hours.
Possible ideas to implement this:
- cron job with a systemctl restart service_name
- systemctl timer with a systemctl restart service_name
A new rule can be entered by:
sudo crontab -e
The new rule could look like:
0 0 * * * /bin/systemctl restart yourService
We need two files, one restart_service.timer
and a restart_service.service:
They have to be copied to
/etc/systemd/system and can be started by:
systemctl enable --now restart_service.timer
When systemctl is newer than version 229, this is a good solution. The version can be found out by:
The manual says about RuntimeMaxSec:
Configures a maximum time for the service to run. If this is used and the service has been active for longer than the specified time it is terminated and put into a failure state. Note that this setting does not have any effect on Type=oneshot services, as they terminate immediately after activation completed. Pass “infinity” (the default) to configure no runtime limit.
This seems to be exactly what I need.
RuntimeMaxSec has to be added to the service file in the
This works for my scripts as they do not run forever. I’m using
RestartSec to restart the script when it is finished.
RuntimeMaxSec seems to me a good measure to robustify systemctl scripts. I will try this on my systemctl services.