CentOS seems to lack easy commands for automatically patching a server and then rebooting it if anything needs restarting.
Basically I want to run a script via /etc/cronttab at regular intervals to patch a system and reboot if necessary. Obviously this might cause an outage (very rarely, some service won't restart), so we do it early in the morning, and we don't patch paired systems at the same time.
My script for Centos 6, 7 or 8 is attached below but it's a bit scrappy! Does anyone have a better way?
(UPDATED 19.6.20: Added 2>&1 stderr redirection to fix issue seen when running from /etc/cronttab on CentOS 8.)