go-algorand-doc
go-algorand-doc copied to clipboard
auto-update systemd service and timer
I noticed that a crontab entry for auto-updates is being used in the Node Setup Guide. I made my own systemd service and timer, which I tested and found works out pretty well. If added to the guide, this will give users the option either to use a systemd service/timer, or a crontab entry if they wish.
algorand-update.service file:
[Unit]
Description=auto-update algorand software
[Service]
Type=oneshot
User=algorand-user
StandardOutput=file:/home/user/node/update.log
StandardError=file:/home/user/node/update.log
ExecStart=/home/user/node/update.sh -d /home/user/node/data
algorand-update.timer file:
[Unit]
Description=auto-update algorand software every hour
[Timer]
# Run hourly
OnCalendar=*-*-* *:00:00
Persistent=true
Unit=algorand-update.service
[Install]
WantedBy=timers.target
edit:
Since systemd services are run as root by default, when an update occurs root will then have ownership of the algorand node folder. If the user running a node isn't root, then the node won't get run since the user no longer has permissions to access the necessary directories/files. Specifying the desired user in the systemd service prevents this issue.
I experienced this same issue. Thanks for pointing out.