We must reboot the server when we install a new kernel or libraries. Ubuntu Linux can tell you if the system needs a reboot when you log in as a root user.
*** System restart required ***
The above warning will appear on the login screen, but we may miss this warning. So here is the simple script for administrators to find out exactly when the system requires a reboot.
You can manually find the file /var/run/reboot-required, which indicates that a system restart is required.
Instead of a manual search, you can use the following script to identify the Ubuntu notification of ‘system restart required’ at every login and never miss the warning.
Add the following lines in the file /root/status.sh :-
#!/bin/bash
if [ -f /var/run/reboot-required ]
then
echo -e “33[33;31m[*** Hello $USER, you must reboot your machine ***’]33[0m”
else
echo -e ‘”33[33;32m\n*** System reboot NOT required now ***\n’cat /var/lib/update-notifier/updates-available’ \n33[0m”
fi
Now we can add the file path /root/status.sh in /root/.bashrc file to check the ‘Reboot required’ task at every login made by the root user.
# echo “/root/status.sh” >> /root/.bashrc && tail -n3 /root/.bashrc


Leave a Reply