Skip to content

Instantly share code, notes, and snippets.

@apinter
Last active May 30, 2022 17:27
Show Gist options
  • Save apinter/2a056b649a0d643575513a000cbbb2bf to your computer and use it in GitHub Desktop.
Save apinter/2a056b649a0d643575513a000cbbb2bf to your computer and use it in GitHub Desktop.
Automated download of rpm packages with systemd and zypper
  1. Create a systemd service and a timer unit with the below contents
  2. The units must run with root so create the units under /etc/systemd/system/
  3. Enable the timer only (systemctl enable --now zypper-dup-download-only.timer)
  4. Use zypper dup whenever you ready to update, packages will be cached daily by the units.

Contents of zypper-dup-download-only.service:

[Unit]
Description=Download available updates
StartLimitBurst=2
StartLimitIntervalSec=30

[Service]
Type=oneshot
Restart=on-failure
ExecStartPre=/usr/bin/zypper ref
ExecStart=/usr/bin/zypper dup --download-only -y
RemainAfterExit=yes

[Install]
WantedBy=default.target

Contents of zypper-dup-download-only.timer:

[Unit]
Description=Download available rpm package updates daily

[Timer]
OnCalendar=daily
Persistent=true

[Install]
WantedBy=timers.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment