Proper use of checkrestart
Hi Everyone,
I have a script that fully updates a machine each night around 4:00
AM. It also reboots the machine as required.
I noticed Debian has checkrestart. The man page is at
https://manpages.debian.org/bullseye/debian-goodies/checkrestart.8.en.html.
I want to ensure I understand "Exit Status" correctly:
Normally, the program will exit with error (1) if a non-root user tries
to run it. Otherwise, it will always exit with error status 0.
If the --terse switch is given, the exit code is 1 when there are
deleted open files and 0 when there are none. This is intended for
consumption by Nagios and similar automated monitoring tools.
I think the script should use --terse, as in:
if command -v checkrestart >/dev/null 2>&1;
then
if ! checkrestart --terse >/dev/null 2>&1;
then
needs_reboot=1
fi
fi
I think using an option like --terse is unusual to get an exit code
that can be used in a script. I want to ensure it is correct.
My question is, is that usage correct?
Thanks in advance.
Reply to: