Best way to automate "zypper dup" via cron

I was wondering what’s the best way to automate the “zypper dup” command using cron for openSUSE Tumbleweed. I already have kcron installed and can easily set up a task as root: My curiosity is what parameters I should use for the zypper command to avoid any prompts, so updates can be automatically installed at the given hour without someone having to type “y” after seeing the package list or “yes” for a license prompt.

My only uncertainty is what the process will do in case of temporary dependency issues. If possible I’d like to make it pick the solution “break Whatever by ignoring some of its dependencies”, as this has never caused any actual issues and usually gets resolved within a few hours. If not I’m fine with the automated update process being skipped when it detects conflicts.

Info is in the zypper MAN pages, but is also in my zypper Wiki on most common commands used in scripted installs
https://en.opensuse.org/User:Tsu2/BASH_zypper

And, an example of an unattended (automated, no User interaction) install… Which probably does a lot more than you want or need (like detecting TW vs LEAP and auto configuring the repo URL)
https://github.com/putztzu/lc0/blob/…penSUSE_lc0.sh

TSU

Thank you. It seems to be as simple as using “zypper -n dup”. Does this skip license prompts as well? What does it do in the case of detecting package issues?

An even better way is using systemd. You may use units packagekit-background.timer and packagekit-background.service as a template for zypper timer and service units in folder /etc/systemd/system.

There is another required option you have to specify to auto agree licenses, and whenever there is a package conflict, the default will be option 1.
It’s in the zypper MAN pages and the example I provided the link.

TSU

“zypper -n dup -l” should be it then. Is this correct? Thanks!

From my example

Line 13

# Update system, always a good idea before a major install
zypper dup -y

and if you need to install packages unattended

Line 54
(note these are options I prefer to allow when recommended by the openSUSE maintainers)

zypper in -y --allow-vendor-change --allow-downgrade 

HTH,
TSU

Hi
I would suggest a read of the /etc/zypper.conf and /etc/zypper/zypp.conf, especially with the latter as it might be advisable to set the download all packages option before proceeding, then if something goes pear shaped, at least the packages will be present on the system… you can also disable some of the options your adding on the command line.

The zypper-log command will also be your friend…


zypper-log -d 2019-08-11
Reading /var/log/zypper.log ............... DONE

TIME              PID    VER      CMD
2019-08-11 09:18  14756  1.14.28  zypper ref
2019-08-11 09:19  15408  1.14.28  zypper -vvv dup
2019-08-11 09:21  29329  1.14.29  zypper ps -s

zypper-log 15408

2019-08-11 09:19:07 <1> grover(15408) [zypper] main.cc(main):74 ===== Hi, me zypper 1.14.28
.....
.....
2019-08-11 09:21:11 <1> grover(15408) [zypp++] MediaHandler.cc(removeAttachPoint):181 MediaHandler - checking if to remove attach point

My zypper -vv dup took just under two minutes… :wink: