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

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • 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. How to Setup a sudo Switch to Another User That Has no Password or ssh Key Set in Linux
  2. How to Reserve a Port Range for a Third Party Application in CentOS/RHEL
  3. How to clean YUM cache in CentOS / RHEL
  4. How to Configure rsyslog to Filter/discard Specific IP Address in CentOS/RHEL 6,7
  5. Inconsistent Device Names Across Reboot Cause Mount Failure Or Incorrect Mount in Linux
  6. CentOS / RHEL : anacron basics (What is anacron and how to configure it)
  7. Maintaining Linux filesystems using “fsck” and “tune2fs”
  8. CentOS / RHEL : How to find UUID of a device or filesystem
  9. Bash for loop Examples
  10. How to change the default permissions on /var/log/audit/audit.log file in CentOS/RHEL

You May Also Like

Primary Sidebar

Recent Posts

  • How to disable ACPI in CentOS/RHEL 7
  • How to Use real-time query to access data on a physical standby database
  • CentOS/RHEL 8: “ACPI MEMORY OR I/O RESET_REG” Server Hung after reboot
  • How to Create a Physical Standby Database by Using SQL and RMAN Commands
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary