A FreeBSD oneliner this time.
This won’t work on Linux!
Tools like portmaster and portupgrade allow you to update all installed ports/packages in a single run, which is great.
But these tools do not list the ports and packages that have been upgraded, leaving you to guess which daemons and services must be restarted…
Luckily, all installed packages are registered in an SQLite database, together with a timestamp for their last upgrade (or installation). Add the following alias to your ~/.bashrc:
alias puptd='sqlite3 /var/db/pkg/local.sqlite "select origin from packages where time > $(date -v-2d +%s) order by origin" | less'
Clearly, if you don’t use the Bash shell, you should figure out how to add aliases in your shell. The alias will be active after you re-login; invoke it like any other command.
This alias will list all ports/packages that were updated (or installed) in the last 2 days (an update of all ports can run for quite some time). Obviously you should feel free to change the -v-2d to any other period (-v-3H for the last 3 hours, -v-1w for the last week, …). You can then check the list to see if any services must be restarted, configurations must be verified, etc.
Remember that some services may depend on other packages. E.g. if you updated Python, you may have to restart Radicale and Fail2ban, and if you updated PHP and you use mod_php, you may want to restart Apache.
If you’re going to play around with that database to see what other info you can extract from it, you should probably make a copy of it, to make sure you don’t accidentally write to the original; you don’t want to mess up your package database.
P.s.: the name for the alias comes from ‘Ports UPdated ToDay’; change it to anything you like.