1. Create a systemd service file:
Create a new service file named zypper-auto-update.service
in the directory /etc/systemd/system/
. You can use any text editor to create and edit this file. For example:
sudo nano /etc/systemd/system/zypper-auto-update.service
Add the following content to the file:
[Unit]
Description=Run zypper update
Wants=network-online.target
After=network-online.target
[Service]
Type=oneshot
ExecStart=/usr/bin/zypper --non-interactive --no-gpg-checks --quiet refresh && /usr/bin/zypper --non-interactive --no-gpg-checks --quiet update
[Install]
WantedBy=multi-user.target
Save the file and exit the text editor.
2. Create a systemd timer file:
Create a new timer file named zypper-auto-update.timer
in the directory /etc/systemd/system/
. This file will specify when and how often the zypper-auto-update.service should be executed. For example:
sudo nano /etc/systemd/system/zypper-auto-update.timer
Add the following content to the file to schedule daily updates at 4 AM:
[Unit]
Description=Run zypper update daily
[Timer]
OnCalendar=*-*-* 04:00:00
Persistent=true
[Install]
WantedBy=timers.target
Save the file and exit the text editor.
3. Reload systemd manager configuration:
After creating the service and timer files, you need to reload the systemd manager configuration to make systemd aware of the new files. Run the following command:
sudo systemctl daemon-reload
4.Enable and start the timer:
Now, enable the timer to start automatically at boot and start it immediately:
sudo systemctl enable --now zypper-auto-update.timer