sometimes the most simple things are the trickiest X-D
the question was, why if shutdown -r now is specified in a script or crontab directly: why won’t the server reboot (to activate newly via updates installed kernel?)
the answer: crontab can not find the binary unless absolute path is given X-D
hostnamectl; # tested on Icon name: computer-vm Chassis: vm Virtualization: kvm Operating System: Debian GNU/Linux 12 (bookworm) Kernel: Linux 6.1.0-26-amd64 Architecture: x86-64 su - root crontab -e # every day at 03:00 try to run automatic updates 3 4 * * * /scripts/update.sh vim /scripts/update.sh #!/bin/bash echo "=== attempting automatic daily update on $(date '+%Y-%m-%d-%H:%M:%S') ===" | tee -a /scripts/update.sh.log apt update 2>&1 | tee -a /scripts/update.sh.log apt -y upgrade 2>&1 | tee -a /scripts/update.sh.log echo "=== automatically removing un-needed packages (and old kernels) ===" # keeping too many old kernel versions might fill up boot partition apt -y autoremove | tee -a /scripts/update.sh.log echo "=== fine ===" | tee -a /scripts/update.sh.log echo "" | tee -a /scripts/update.sh.log echo "... in order to run latest kernel, reboot is required" /scripts/reboot.sh vim /scripts/reboot.sh #!/bin/bash echo "...as gracefully as possible: reboot the system" echo "... stop all kvm vms" # /scripts/stop.sh sync; sync; sync; /sbin/shutdown -r now; # SPECIFY ABSOLUTE PATH!!!!
liked this article?
- only together we can create a truly free world
- plz support dwaves to keep it up & running!
- (yes the info on the internet is (mostly) free but beer is still not free (still have to work on that))
- really really hate advertisement
- contribute: whenever a solution was found, blog about it for others to find!
- talk about, recommend & link to this blog and articles
- thanks to all who contribute!