auto update debian 13
1. Install Required Packages
Install the update utility and the mail tools needed to send notifications.
bash
sudo apt update && sudo apt upgrade -y
sudo apt install unattended-upgrades apt-listchanges bsd-mailx msmtp msmtp-mta -y 2. Configure msmtp (Zoho Mail)
Create and secure the mail configuration file at
/etc/msmtprc.- Edit the file:
sudo nano /etc/msmtprc - Add your Zoho settings:ini
defaults auth on tls on tls_starttls on tls_trust_file /etc/ssl/certs/ca-certificates.crt logfile /var/log/msmtp.log account zoho host smtp.zoho.com port 587 from your-email@zoho.com user your-email@zoho.com password your-regular-password account default : zohoSet Permissions:bashsudo groupadd -f msmtp sudo chown root:msmtp /etc/msmtprc sudo chmod 640 /etc/msmtprcecho "Test body" | msmtp -d rashitha@gmx.com
if permission error
sudo usermod -aG msmtp rasitha
test echo "Test body" | msmtp -d rashitha@gmx.comif unsuccessfulsudo usermod -aG msmtp root
if unsuccessfulsudo chmod 777
/etc/msmtprc3. Configure Auto-Updates (All Packages)Edit the main configuration file to include all repositories and set up the email link.- Edit the file:
sudo nano /etc/apt/apt.conf.d/50unattended-upgrades - Enable all repositories: Add
"origin=*";inside theUnattended-Upgrade::Origins-Patternblock. - Set email notifications:
Unattended-Upgrade::Mail "rashitha@gmx.com";Unattended-Upgrade::Sender "rasitha@zohomail.com";Unattended-Upgrade::MailReport "always";(Change to"on-change"once tested)sudo unattended-upgrade -d
4. Schedule the Time (2:00 AM)Override the default systemd timers to run at your preferred time.- Edit the upgrade timer:
sudo systemctl edit apt-daily-upgrade.timer. - Add the schedule:ini
[Timer]
OnCalendar=
OnCalendar=*-*-* 11:04:00
RandomizedDelaySec=0
Persistent=trueRestart timers:bashsudo systemctl enable --now apt-daily.timersudo systemctl enable --now apt-daily-upgrade.timersudo systemctl daemon-reloadsudo systemctl restart apt-daily-upgrade.timersystemctl list-timers | grep aptsudo nano /etc/apt/apt.conf.d/20auto-upgradesAPT::Periodic::Update-Package-Lists "always"; APT::Periodic::Unattended-Upgrade "always";how to checksudo unattended-upgrade -dmail logsudo tail -f /var/log/msmtp.log
5. Final Verification- Enable the service:
sudo dpkg-reconfigure --priority=low unattended-upgrades. - Dry Run Test:
sudo unattended-upgrade --debug --dry-run. - Check Logs: Use
tail -f /var/log/msmtp.logortail -f /var/log/unattended-upgrades/unattended-upgrades.logto monitor future activity.
- Enable the service:
- Edit the file:
Comments
Post a Comment