Accidental shutdown or reboot is a serious blunder, especially if the kernel is being updated in the background.
I recommend you to use systemd-inhibit to prevent Linux from shutting down while your important cron jobs are running (e.g. operating system update scripts):
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