Accidental shutdown or reboot is a serious blunder, especially if the kernel is being updated in the background.
In order to prevent Linux from shutting down while your update script is running, I recommend you to use systemd-inhibit:
systemd-inhibit --why="Doing update" ./my-update-script.sh
systemd-inhibit will block the shutdown or reboot until the update script is finished.
- –who=”your name”
A human-readable name
List all active inhibition locks