Setup a cron job to automate updates

Install cron

sudo apt install cron
sudo systemctl enable cron

Next, we setup the job in the crontab file

sudo nano /etc/crontab

The fields in the syntax are listed in the following table along with the allowed values for each field.

Field Values allowed
Minute 0 to 59
Hour 0 to 23
Day of month 1 to 31
Month 1 to 12 OR JAN to DEC
Day of week 0 to 6 OR SUN to SAT
Apart from this, you can use a special character as * (asterisk). This is used to denote ‘each’. For example, if you wished to run a command each Wednesday at 5 PM, you use the following entry.

1 0 17 * * 3 [command]
This will run [command] on the fourth day of the week (Wednesday, we use 3 because computers count from a 0), every month and every day of a month (because these are denoted by an asterisk, at 17 hours and 0 minutes (5:00 PM). Some newer cron daemons may allow for a special syntax. These special entries along with what they represent is given in the table below.

Special Syntax Regular equivalent
@hourly 0 * * * *
@daily 0 0 * * *
@weekly 0 0 * * 0
@monthly 0 0 1 * *
@yearly 0 0 1 1 *

0 0     * * *     root /usr/bin/apt update -q -y >> /var/log/apt/automaticupdates.log
0 0     * * *     root /usr/bin/apt upgrade -q -y >> /var/log/apt/automaticupdates.log
CTRL + O to save the file
CTRL + X to exit nano

https://www.linuxfordevices.com/tutorials/linux/automatic-updates-cronjob