A general comment: Instead of using sudo
in the user
crontab, consider putting these commands in the root
crontab, so they can run without sudo.
As for your 3 crontab lines:
@midnight sudo apt-get update && sleep 60 && apt-get upgrade -y
It's perfectly viable to do apt-get update
and apt-get upgrade -y
in this way. (Not intended for a production server, and under the condition that you understand the implications of unattended upgrades.)
00 02 * * 1,3,5 sudo shutdown -r
I wouldn't think it's necessary to reboot 3 times a week. I myself use this very simple reboot script: (called auto-reboot.sh
)
#!/bin/bash
[[ -f /var/run/reboot-required.pkgs ]] && reboot
So I run this script with cron weekly, after my upgrade and cleanup script. It only reboots if the machine needs to be rebooted (if /var/run/reboot-required.pkgs
exist). (Again, this is not intended for a production server.)
@reboot sleep 60 && sudo netplan apply && sleep 15 && sudo omd start website
I don't understand why you would need to run netplan apply
on reboot.
Also, a more reliable way to start a service that is depending on another service or condition (e.g. network) is to create a systemd .service
to do the job. There are several tutorials for this (1, 2), that I would recommend you take a look at.