Check if reboot is required in Ubuntu.
at /var/run/reboot-required *** System restart required *** |
cloud engineer
Check if reboot is required in Ubuntu.
at /var/run/reboot-required *** System restart required *** |
at /var/run/reboot-required *** System restart required ***
Here’s the command to check if the system needs a reboot after running yum update.
Must be root or run it sudo.
$ needs-restarting -r ; echo $? Core libraries or services have been updated: openssl-libs -> 1:1.0.2k-21.el7_9 kernel -> 3.10.0-1160.31.1.el7 dbus -> 1:1.10.24-15.el7 linux-firmware -> 20200421-80.git78c0348.el7_9 glibc -> 2.17-324.el7_9 systemd -> 219-78.el7_9.3 Reboot is required to ensure that your system benefits from these updates. More information: https://access.redhat.com/solutions/27943 1 |
$ needs-restarting -r ; echo $? Core libraries or services have been updated: openssl-libs -> 1:1.0.2k-21.el7_9 kernel -> 3.10.0-1160.31.1.el7 dbus -> 1:1.10.24-15.el7 linux-firmware -> 20200421-80.git78c0348.el7_9 glibc -> 2.17-324.el7_9 systemd -> 219-78.el7_9.3 Reboot is required to ensure that your system benefits from these updates. More information: https://access.redhat.com/solutions/27943 1
In this instance, it requires a reboot due to a new kernel.
Here’s a new script to reboot a Lightsail instance based on input.
#!/bin/bash echo 'Choose a server to reboot ...' echo '1) server-one' echo '2) server-two' echo '3) server-three' echo '4) server-four' echo '5) sever-five' echo 'q) Quit' read -p 'Choose a server to reboot: ' server case $server in 1) echo 'Rebooting server-one ...' aws lightsail reboot-instance --instance-name server-one echo 'Done' ;; 2) echo 'Rebooting server-two ...' aws lightsail reboot-instance --instance-name server-two echo 'Done' ;; 3) echo 'Rebooting server-three ...' aws lightsail reboot-instance --instance-name server-three echo 'Done' ;; 4) echo 'Rebooting server-four ...' aws lightsail reboot-instance --instance-name server-four echo 'Done' ;; 5) echo 'Rebooting server-five ...' aws lightsail reboot-instance --instance-name server-five echo 'Done' ;; q) echo 'Quit' ;; *) echo 'Invalid option' $server ;; esac |
#!/bin/bash echo 'Choose a server to reboot ...' echo '1) server-one' echo '2) server-two' echo '3) server-three' echo '4) server-four' echo '5) sever-five' echo 'q) Quit' read -p 'Choose a server to reboot: ' server case $server in 1) echo 'Rebooting server-one ...' aws lightsail reboot-instance --instance-name server-one echo 'Done' ;; 2) echo 'Rebooting server-two ...' aws lightsail reboot-instance --instance-name server-two echo 'Done' ;; 3) echo 'Rebooting server-three ...' aws lightsail reboot-instance --instance-name server-three echo 'Done' ;; 4) echo 'Rebooting server-four ...' aws lightsail reboot-instance --instance-name server-four echo 'Done' ;; 5) echo 'Rebooting server-five ...' aws lightsail reboot-instance --instance-name server-five echo 'Done' ;; q) echo 'Quit' ;; *) echo 'Invalid option' $server ;; esac
Assuming awscli is working and correct permission is granted to user.
Here’s a simple adhoc to run updates on systems in Ansible.
ansible servers -m apt -a "upgrade=yes update_cache=yes" -b |
ansible servers -m apt -a "upgrade=yes update_cache=yes" -b
Results:
server | SUCCESS => { "changed": false, "msg": "Reading package lists... Building dependency tree... Reading state information... Calculating upgrade... 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.", "stderr": "", "stderr_lines": [], "stdout": "Reading package lists... Building dependency tree... Reading state information... Calculating upgrade... 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.", "stdout_lines": [ "Reading package lists...", "Building dependency tree...", "Reading state information...", "Calculating upgrade...", "0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." ] } |
server | SUCCESS => { "changed": false, "msg": "Reading package lists... Building dependency tree... Reading state information... Calculating upgrade... 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.", "stderr": "", "stderr_lines": [], "stdout": "Reading package lists... Building dependency tree... Reading state information... Calculating upgrade... 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.", "stdout_lines": [ "Reading package lists...", "Building dependency tree...", "Reading state information...", "Calculating upgrade...", "0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." ] }
If you want to reboot a remote server.
ansible servers -m "reboot" -b |
ansible servers -m "reboot" -b
To automatically mount a EFS volume after each reboot, you’ll need to add the following format to /etc/fstab.
You can use the DNS name given by AWS.
fs-12345678:/ /mnt/efs efs defaults,_netdev 0 0 |
fs-12345678:/ /mnt/efs efs defaults,_netdev 0 0
Or the IP address.
10.0.0.22:/ /mnt/efs efs defaults,_netdev 0 0 |
10.0.0.22:/ /mnt/efs efs defaults,_netdev 0 0
Mount all with fake and verbose.
mount -fav |
mount -fav