This guide should work for recent versions of an OpenBSD operating system. It covers only packages updates/upgrades, and does not apply any other patch to the base system or kernel.

NOTE: All steps documented on this page are considering that your server is dedicated to provide a Tor relay. Please be aware that services will be restarted during the automatic software update process documented here.

1. Create the Update Script

OpenBSD offers us an easy way of running tasks daily, weekly or monthly. It allows us to write our own custom scripts to be called by cron in three different local files (depending on our needs, or particular choices):

  • /etc/daily.local
  • /etc/weekly.local
  • /etc/monthly.local

For this example, we are going to use /etc/weekly.local:

RAND=$(jot -r 1 900)
sleep ${RAND}
pkg_add -u -I && \
rcctl restart tor

For this particular schedule, we opt to run the script every week on Saturdays at 3h30 (depending on your timezone). It will trigger the packages updates process itself, depending on the value set to the $RAND variable. It's configured to produce a sleep between 0 and 900 seconds (15 minutes).

2. Restart cron

Finally, restart the cron daemon to make configuration changes be used.

# rcctl restart cron