Centos – What would happen if I schedule a shutdown in the middle of an update

centosshutdownyum

I did an update of CentOS 6 last night which was rather large. By the time I decided to leave it to finish, the process was only a few packages away from completing the download. So, I scheduled a shutdown for +60 minutes and left.

When I checked in on the system this morning it had shutdown. I'm having some troubles (I expected something), only, while I was looking at logs, I noticed the end of the yum log seems like the update took longer then I expected.

When I noticed this, I reran yum update. Everything is up to date. Another question is,

Did it finish cleanly. How can I check?

Best Answer

On CentOS the file /var/log/yum.log shall have the time the last package was upgraded. For example on my CentOS (mine is currently running CentOS 7, but the file is in the same place):

# tail -n 3 /var/log/yum.log
Jun 28 17:10:04 Updated: 1:mariadb-libs-5.5.47-1.el7_2.x86_64
Jun 28 17:10:05 Updated: graphite2-1.3.6-1.el7_2.x86_64
Jun 28 17:10:05 Updated: zsh-5.0.2-14.el7_2.2.x86_64

(Yes, I did not run yum update for some time)

You can then compare this against syslog messages about the shutdown. Syslog rotates the logs, so you may have something like messages-20160807 instead of plain messages, check that too. For example:

# egrep -i 'stopped|shut' /var/log/messages*
/var/log/messages-20160731:Jul 24 23:55:55 orion systemd: Stopped target Multi-User System.
/var/log/messages-20160731:Jul 24 23:55:55 orion systemd: Stopped Resets System Activity Logs.
/var/log/messages-20160731:Jul 24 23:55:57 orion systemd: Stopped Permit User Sessions.
/var/log/messages-20160731:Jul 24 23:55:57 orion systemd: Stopped target Remote File Systems.
/var/log/messages-20160731:Jul 24 23:56:33 orion systemd[1]: Listening on Delayed Shutdown Socket.
/var/log/messages-20160731:Jul 24 23:56:33 orion systemd[1]: Starting Delayed Shutdown Socket.

(CentOS 6 will not have systemd messages, but something relevant will be printed.)

Depending on the configuration in /etc/rsyslog.conf//etc/syslog.conf shutdown may not be logged, but something certainly logs when the system goes down. Therefore searching for stopped|shut is a good heuristic to check when things started going down.

Comparing the timestamps in both logs you can get a good notion of whether yum finished its work before the system went down.

Related Question