• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to Check if a Service Restart or Server Reboot is required After RPM Package Update (CentOS/RHEL/Fedora)

by admin

After reading this post you will know which services need to be restarted after updating one or more RPM packages. Also, you will know if a server reboot is needed after updating one or more RPM packages.

needs-restarting utility of yum

The command /sbin/needs-restarting out of the package yum-utils compares the mapped libraries of the running processes with their counterparts on disk and list processes with out of date copies in memory. The list allows identifying services and processes which needs to be restarted after the update.

Patience Please

The needs-restarting(1) tool described here can take a considerable amount of running time since it checks many services and library relationships. However, running the needs-restarting tool after any RPM update, such as by rpm or yum, is recommended.

Check Services To Restart

1. To see a list of processes that started running before they or some component they use were updated, do this:

# needs-restarting
2438 : /usr/libexec/hald-addon-generic-backlight
2458 : hald-addon-storage: polling /dev/sr0 (every 2 sec)
2847 : xinetd-stayalive-pidfile/var/run/xinetd.pid
2457 : hald-addon-acpi: listening on acpid socket /var/run/acpid.socket
2452 : hald-addon-input: Listening on /dev/input/event7 /dev/input/event0 /dev/input/event2 /dev/input/event1
27729 : rpc.statd
24992 : /usr/sbin/named-unamed
1 : /sbin/init
972 : /usr/sbin/sshd
12560 : /sbin/udevd-d
2406 : hald-runner
2036 : rpcbind-w
2405 : hald
2178 : irqbalance--pid=/var/run/irqbalance.pid
2070 : /sbin/rsyslogd-i/var/run/syslogd.pid-c5
24450 : /sbin/udevd-d
2763 : tgtd
2819 : /usr/sbin/mcelog--daemon
2766 : tgtd
2930 : crond
589 : /sbin/udevd-d
2979 : /sbin/mingetty/dev/tty6
2977 : /sbin/mingetty/dev/tty5
2975 : /sbin/mingetty/dev/tty4
2339 : dbus-daemon--system
29738 : /usr/sbin/console-kit-daemon--no-daemon
29510 : /sbin/mingetty/dev/tty1 
#

2. In this example PID 972 (/usr/sbin/sshd) needs restarting. (pid=972) needs to be restarted, which is provided by sshd service.

# needs-restarting | fgrep 972
972 : /usr/sbin/sshd

3. This executable is provided by the openssh-server RPM package.

# rpm -qf /usr/sbin/sshd
openssh-server-5.3p1-123.el6_9.x86_64
# rpm -qf /usr/sbin/sshd -l | fgrep .serv
/usr/lib/systemd/system/sshd.service
...

4. Thus restarting sshd service results that /usr/sbin/sshd is removed from the list.

# service sshd restart
stopping sshd [ OK ]
starting sshd [ OK ]
# needs-restarting | fgrep ssh

If no process needs to be restarted, needs-restarting shows nothing. If something is shown but can not be removed even after restarting relevant services, the system needs to reboot OS.

Check If Server Restart Needed (CentOS/RHEL 7 and later)

Some services cannot be restarted without destablizing the server. To check for these cases, CentOS/RHEL 7 and later support a -r command line switch:

# needs-restarting -r
Core libraries or services have been updated:
  dbus -> 1:1.10.24-7.0.1.el7

Any output from this command form indicates a system reboot is recommended.

Filed Under: CentOS/RHEL 5, CentOS/RHEL 6, CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. xfs_admin: command not found
  2. pinky Command Examples in Linux
  3. homectl Command Examples in Linux
  4. bpftool: command not found
  5. Understanding TCP Wrappers (/etc/hosts.allow & /etc/hosts.deny) in Linux
  6. sa Command Examples in Linux
  7. arp Command Examples in Linux
  8. /etc/rsyslog.conf – Setup a Filter to Discard or Redirect Messages
  9. namei: command not found
  10. LVM VG Metadata Corruption with ‘Checksum error’

You May Also Like

Primary Sidebar

Recent Posts

  • pw-cat Command Examples in Linux
  • pvs: command not found
  • pulseaudio: command not found
  • pulseaudio Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright