#!/bin/sh host=`hostname -f` date=`date` # run updates to get latest software and kernel yum -y update maxdelay=$((6*60)) rdelay=$(($RANDOM%maxdelay)) sdelay=$(($rdelay*60)) kernel=`uname -r` latest=`rpm -q kernel --queryformat '%{installtime} %{version}-%{release}.%{arch}\n' | sort -n -k1 | tail -1 | cut -d ' ' -f 2` sdate=`date` if [ "$kernel" = "$latest" ]; then echo "No need to reboot..." echo "You are running the latest kernel: $kernel" else echo "There is a new kernel. You need a reboot..." echo "Current kernel: $kernel" echo "The latest kernel: $latest" echo "$sdate\nCurrent kernel: $kernel\nLatest kernel: $latest" echo "Sleeping for $sdelay seconds..." sleep $sdelay echo "Waking up and rebooting..." /sbin/reboot fi
Monday, 17 July 2017
Update, compare kernel versions - reboot within 6hours period - CentOS
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment