I’m writing a script to update the system during Saturday night and reboot if necessary.
In ubuntu there is a file named /var/run/reboot-required when reboot is necessary. Is there something similar in OpenSuse?
regards
I’m writing a script to update the system during Saturday night and reboot if necessary.
In ubuntu there is a file named /var/run/reboot-required when reboot is necessary. Is there something similar in OpenSuse?
regards
If you use Yast Online Update, it does tell you to reboot or to logout/login again. I think it’s a message attached to a patch. But I don’t know of any file.
There’s a file, something like “/boot/purge-kernels” that is created on a kernel update, and that’s the main time that you need to reboot.
But I’m using it from a script.
There’s a file, something like “/boot/purge-kernels” that is created on a kernel update, and that’s the main time that you need to reboot.
Well, thibking on a kernel update It can work something like this:
#!/bin/bash
/usr/bin/zypper refresh --non-interactive
/usr/bin/zypper update --non-interactive --auto-agree-with-licenses
/usr/bin/zypper ps -s |grep -q 'kernel'; &> /dev/null
if $? == 0 ]; then
/sbin/reboot
fi
Is there the kernel the only “package” wich needs rebooting?
By the way, it may be neccesary to reboot other things, and I can put them in the sript something like
/usr/bin/zypper ps -s |grep -q 'postfix'; &> /dev/null
if $? == 0 ]; then
/sbin/service postfix restart
fi
regards
I’m not sure if there are others. I just don’t recall any.
There are some other critical components, such as “systemd”, but those are usually restarted as part of the update.
The actual file is: “/boot/do_purge_kernels”.
It should be present after a kernel update, but it will disappear shortly after reboot. The “purge-kernels” service checks for that file, and removes old kernels as needed. And it removes that flag file.
Hi,
One comment on your script, you can remove the **if **clause in your script and just directly run whatever command you want after grepping the output of **zypper ps -s ** eg
zypper ps -s | grep -q postfix && echo 'found postfix'
No need to test the exit status of grep. Well if you really want the if clause then.
if zypper ps -s | grep -q postfix; then echo 'postfix found'; fi
the echo is there just to show you that it found something or not, replace it with the command you want to run instead.
Also the I’m not sure what the ; &>/dev/null is all about. Any how at the end of the day it is still your script so you can always ignore my advice
Yes, that looks better than mine
Also the I’m not sure what the ; &>/dev/null is all about. Any how at the end of the day it is still your script so you can always ignore my advice
It’s anabbreviation
Best regards
Right it is, but what I’m saying is, why do have it at the next line after the command.
The **; **in shell syntax means a newline, so my question is what are you redirecting to /dev/null ?
I’m afraid I’m redirecting nothing to /dev/null
You’re right again. Semicolon away!!!
best regards