$ -weight: 600;">sudo -weight: 500;">apt -weight: 500;">update
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">install needrestart
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">update
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">install needrestart
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">update
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">install needrestart
needrestart -v
needrestart -v
needrestart -v
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">upgrade
-weight: 600;">sudo needrestart -r l
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">upgrade
-weight: 600;">sudo needrestart -r l
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">upgrade
-weight: 600;">sudo needrestart -r l
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">upgrade
-weight: 600;">sudo needrestart -r l
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart nginx
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart myapp.-weight: 500;">service
-weight: 600;">sudo needrestart -r l
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">upgrade
-weight: 600;">sudo needrestart -r l
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart nginx
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart myapp.-weight: 500;">service
-weight: 600;">sudo needrestart -r l
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">upgrade
-weight: 600;">sudo needrestart -r l
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart nginx
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart myapp.-weight: 500;">service
-weight: 600;">sudo needrestart -r l
-weight: 500;">systemctl -weight: 500;">status nginx --no-pager
-weight: 500;">systemctl -weight: 500;">status myapp.-weight: 500;">service --no-pager
-weight: 500;">systemctl -weight: 500;">status nginx --no-pager
-weight: 500;">systemctl -weight: 500;">status myapp.-weight: 500;">service --no-pager
-weight: 500;">systemctl -weight: 500;">status nginx --no-pager
-weight: 500;">systemctl -weight: 500;">status myapp.-weight: 500;">service --no-pager
-weight: 600;">sudo needrestart -b
-weight: 600;">sudo needrestart -b
-weight: 600;">sudo needrestart -b
NEEDRESTART-VER: 2.1
NEEDRESTART-KCUR: 3.19.3-tl1+
NEEDRESTART-KEXP: 3.19.3-tl1+
NEEDRESTART-KSTA: 1
NEEDRESTART-SVC: systemd-journald.-weight: 500;">service
NEEDRESTART-SVC: systemd-machined.-weight: 500;">service
NEEDRESTART-VER: 2.1
NEEDRESTART-KCUR: 3.19.3-tl1+
NEEDRESTART-KEXP: 3.19.3-tl1+
NEEDRESTART-KSTA: 1
NEEDRESTART-SVC: systemd-journald.-weight: 500;">service
NEEDRESTART-SVC: systemd-machined.-weight: 500;">service
NEEDRESTART-VER: 2.1
NEEDRESTART-KCUR: 3.19.3-tl1+
NEEDRESTART-KEXP: 3.19.3-tl1+
NEEDRESTART-KSTA: 1
NEEDRESTART-SVC: systemd-journald.-weight: 500;">service
NEEDRESTART-SVC: systemd-machined.-weight: 500;">service
#!/usr/bin/env bash
set -euo pipefail out=$(-weight: 600;">sudo needrestart -b) echo "$out" if grep -q '^NEEDRESTART-KSTA: [23]$' <<<"$out"; then echo "Kernel reboot pending"
fi if grep -q '^NEEDRESTART-SVC:' <<<"$out"; then echo "One or more services need -weight: 500;">restart"
fi
#!/usr/bin/env bash
set -euo pipefail out=$(-weight: 600;">sudo needrestart -b) echo "$out" if grep -q '^NEEDRESTART-KSTA: [23]$' <<<"$out"; then echo "Kernel reboot pending"
fi if grep -q '^NEEDRESTART-SVC:' <<<"$out"; then echo "One or more services need -weight: 500;">restart"
fi
#!/usr/bin/env bash
set -euo pipefail out=$(-weight: 600;">sudo needrestart -b) echo "$out" if grep -q '^NEEDRESTART-KSTA: [23]$' <<<"$out"; then echo "Kernel reboot pending"
fi if grep -q '^NEEDRESTART-SVC:' <<<"$out"; then echo "One or more services need -weight: 500;">restart"
fi
-weight: 600;">sudo NEEDRESTART_SUSPEND=1 -weight: 500;">apt-get -weight: 500;">upgrade
-weight: 600;">sudo needrestart -r l
-weight: 600;">sudo NEEDRESTART_SUSPEND=1 -weight: 500;">apt-get -weight: 500;">upgrade
-weight: 600;">sudo needrestart -r l
-weight: 600;">sudo NEEDRESTART_SUSPEND=1 -weight: 500;">apt-get -weight: 500;">upgrade
-weight: 600;">sudo needrestart -r l
#!/usr/bin/env bash
set -euo pipefail -weight: 600;">sudo needrestart -r l || true echo
echo "If services are listed, -weight: 500;">restart them selectively with:"
echo " -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart <-weight: 500;">service>"
echo
echo "Then verify again with:"
echo " -weight: 600;">sudo needrestart -r l"
#!/usr/bin/env bash
set -euo pipefail -weight: 600;">sudo needrestart -r l || true echo
echo "If services are listed, -weight: 500;">restart them selectively with:"
echo " -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart <-weight: 500;">service>"
echo
echo "Then verify again with:"
echo " -weight: 600;">sudo needrestart -r l"
#!/usr/bin/env bash
set -euo pipefail -weight: 600;">sudo needrestart -r l || true echo
echo "If services are listed, -weight: 500;">restart them selectively with:"
echo " -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart <-weight: 500;">service>"
echo
echo "Then verify again with:"
echo " -weight: 600;">sudo needrestart -r l"
-weight: 600;">sudo -weight: 500;">install -m 0755 post--weight: 500;">apt--weight: 500;">restart-check /usr/local/sbin/post--weight: 500;">apt--weight: 500;">restart-check
-weight: 600;">sudo -weight: 500;">install -m 0755 post--weight: 500;">apt--weight: 500;">restart-check /usr/local/sbin/post--weight: 500;">apt--weight: 500;">restart-check
-weight: 600;">sudo -weight: 500;">install -m 0755 post--weight: 500;">apt--weight: 500;">restart-check /usr/local/sbin/post--weight: 500;">apt--weight: 500;">restart-check
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">update
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">upgrade
-weight: 600;">sudo /usr/local/sbin/post--weight: 500;">apt--weight: 500;">restart-check
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">update
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">upgrade
-weight: 600;">sudo /usr/local/sbin/post--weight: 500;">apt--weight: 500;">restart-check
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">update
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">upgrade
-weight: 600;">sudo /usr/local/sbin/post--weight: 500;">apt--weight: 500;">restart-check - some updates only require -weight: 500;">service restarts
- some updates leave user sessions or daemons mapped to old libraries
- kernel changes still require a reboot to boot into the new kernel - /var/log/unattended-upgrades/unattended-upgrades.log
- /var/log/unattended-upgrades/unattended-upgrades-dpkg.log - -r l means list-only -weight: 500;">restart mode
- it reports what needs a -weight: 500;">restart without restarting anything
- it can also report whether the running kernel is older than the installed one - NEEDRESTART-SVC lists services that should be restarted
- NEEDRESTART-KCUR is the current kernel
- NEEDRESTART-KEXP is the expected kernel
- NEEDRESTART-KSTA is kernel -weight: 500;">status - 0: unknown or failed to detect
- 1: no pending -weight: 500;">upgrade
- 2: ABI-compatible -weight: 500;">upgrade pending
- 3: version -weight: 500;">upgrade pending - needrestart shows a pending kernel -weight: 500;">upgrade
- you updated something that your own platform policy requires a reboot for
- you want a clean maintenance window reset after broad base-system changes - only specific daemons are using old libraries
- the host runs long-lived services you can -weight: 500;">restart one by one
- you want to avoid rebooting a production node unnecessarily - you restarted the listed services manually
- you are patching a critical host and want proof that stale processes are gone - let unattended-upgrades -weight: 500;">install packages
- review its logs if needed
- use needrestart output to decide between -weight: 500;">service restarts and a reboot - needrestart helps identify stale daemons and pending kernel upgrades, but it is not a substitute for application-specific maintenance knowledge.
- Restarting a -weight: 500;">service may still need coordination if the app has connection draining, clustering, or session-state concerns.
- A clean needrestart -r l result after -weight: 500;">service restarts is strong evidence, but your own change policy still wins. - Debian man page, needrestart(1): https://manpages.debian.org/bookworm/needrestart/needrestart.1.en.html
- Ubuntu man page, needrestart(1): https://manpages.ubuntu.com/manpages/jammy/man1/needrestart.1.html
- Upstream needrestart repository: https://github.com/liske/needrestart
- Upstream batch-mode documentation: https://raw.githubusercontent.com/liske/needrestart/master/README.batch.md
- Debian package metadata for needrestart: https://packages.debian.org/bookworm/needrestart
- Debian man page, unattended--weight: 500;">upgrade(8): https://manpages.debian.org/bookworm/unattended-upgrades/unattended--weight: 500;">upgrade.8.en.html
- Ubuntu man page, unattended--weight: 500;">upgrade(8): https://manpages.ubuntu.com/manpages/jammy/man8/unattended--weight: 500;">upgrade.8.html