Automated script to run zypper dup periodically

Hello everyone

I recently updated my girlfriends laptop (and my own) to KDE 4.4 (using
the Factory repository). I am also using some additional repositories
like PackMan.

I recently read on this forum, that the updater-applet is only updating
from the main repositories (the ones set up after install). I would like
to update from all updates periodically using “zypper dup”.

I read somewhere else, that cronjobs are used to run scripts based on
schedules. Can someone eyplain to me how I could run “zypper dup” with a
cronjob and preferably under root, so I dont have to type the password
every time?

Thanks

Become root

su -

Edit the crontab

crontab -e

Enter the command

05 02 * * * "/usr/bin/zypper dup"

That will run zypper at five minutes past 2am every day of the week. You may need to remove the quotes around the command. I didn’t test it.

Save the crontab, if using Vi do: Shift colon wq

:wq

Exit as root.

If you want to run less frequently read the man page for crontab(5)

man 5 crontab

Thanks a lot. According to the manpage the quotes had to be removed.

Am 14.03.2010 18:16, schrieb udaman:
>
> Become root
>
>
> Code:
> --------------------
> su -
> --------------------
>
>
> Edit the crontab
>
>
> Code:
> --------------------
> crontab -e
> --------------------
>
>
> Enter the command
>
>
> Code:
> --------------------
> 05 02 * * * “/usr/bin/zypper dup”
> --------------------
>
>
> That will run zypper at five minutes past 2am every day of the week.
> You may need to remove the quotes around the command. I didn’t test
> it.
>
> Save the crontab, if using Vi do: Shift colon wq
>
>
> Code:
> --------------------
> :wq
> --------------------
>
>
> Exit as root.
>
> If you want to run less frequently read the man page for crontab(5)
>
>
> Code:
> --------------------
> man 5 crontab
> --------------------
>
>

Thanks a lot. According to the manpage the quotes had to be removed.

Am 14.03.2010 18:16, schrieb udaman:
>
> Become root
>
>
> Code:
> --------------------
> su -
> --------------------
>
>
> Edit the crontab
>
>
> Code:
> --------------------
> crontab -e
> --------------------
>
>
> Enter the command
>
>
> Code:
> --------------------
> 05 02 * * * “/usr/bin/zypper dup”
> --------------------
>
>
> That will run zypper at five minutes past 2am every day of the week.
> You may need to remove the quotes around the command. I didn’t test
> it.
>
> Save the crontab, if using Vi do: Shift colon wq
>
>
> Code:
> --------------------
> :wq
> --------------------
>
>
> Exit as root.
>
> If you want to run less frequently read the man page for crontab(5)
>
>
> Code:
> --------------------
> man 5 crontab
> --------------------
>
>

Thanks a lot. According to the manpage the quotes had to be removed.

Am 14.03.2010 18:16, schrieb udaman:
>
> Become root
>
>
> Code:
> --------------------
> su -
> --------------------
>
>
> Edit the crontab
>
>
> Code:
> --------------------
> crontab -e
> --------------------
>
>
> Enter the command
>
>
> Code:
> --------------------
> 05 02 * * * “/usr/bin/zypper dup”
> --------------------
>
>
> That will run zypper at five minutes past 2am every day of the week.
> You may need to remove the quotes around the command. I didn’t test
> it.
>
> Save the crontab, if using Vi do: Shift colon wq
>
>
> Code:
> --------------------
> :wq
> --------------------
>
>
> Exit as root.
>
> If you want to run less frequently read the man page for crontab(5)
>
>
> Code:
> --------------------
> man 5 crontab
> --------------------
>
>

Running unattended “zypper dup” is one of the worst ideas I ever saw in a forum.

OTOH, running it the way described above will not harm the system, on the contrary, it will save the system from any updates (attended or unattended) from -let’s guess- 2:06 am on.

Why it’s a bad idea and why it will block any updates after running that cron can be found when reading “man zypper”.

Live and learn.

Thanks for your thoughts. I will look into the manpage once I am back on Linux. In the meanwhile, what is so bad when the updates are only applied once a day? I understand the point that it might block updates that come in later that day but this shouldnt be a big problem (most update tools work like that…meaning they run once a day). Or am I completely misunderstanding something here?

Thanks

You may want have security updates automaticaly installed. That can perfectly be configured using YaST. So why to make a cron job yourself?
Some peoplw will never do this, but in your case (a friend where you are not always in the neighbourhood to do this manualy) I would say: “why not?”

But you asked something very different, you wanted to do a* zypper dup* what is inappropriate except when you want to go to 11.3 somewhere in the future and I do not think you will let that happen unattended? That is causing the outcry. But you promised allready to go for the man page, so maybe you come back later with questions about that.

Even a zypper up is not a thing most people want to do automaticaly and unattended. Also there is only use for it when you have others then the standard OSS and non-OSS repos. When you have Packman and say KDE:Stable, I can see some use for it. But I wouldn’t do this more often then say once a week.

In short one should try to calculate the priorty of the updates (security first) against the basicaly three ways to update/upgrade.

I did many many unattended updates with RedHat. I know many others that did auto updates too. I don’t see why OS is any different? It would be much easier for users to get their updates without interaction, you know like Microsoft does. A bit more user friendly.

What he is doing is syncing to the beta repo. I did this once with 10.1 and the KDE repo and got into massive problems. The problem is that this repo is UNSTABLE! It is very early beta. You can introduce all sorts of problems.

Doing an auto update is a whole lot different then syncing against an unstable development repo. That is what factory is. Hope you can see the difference.

I’m using the Factory KDE repos. My KDE version currently is: Platform Version 4.4.1 (KDE 4.4.1) “release 227”

Right now the machine is fast and very stable. Is it suggested that I disable the factory repos at this time?
It was my understanding that all I was updating were bug fixes until the next Beta comes out…please enlighten me as I’m new to openSUSE and use this for work.

thanks

OK, let’s put this straight.

A zypper dup will

a) change vendor if newer version is available

b) downgrade a package if a package from a repo is temporarily unavailable (due to syncing the mirrors hasn’t been completed at that time, which happens regularly on large, inofficial repos with lots of packages like the KDE:KDEwhatever-Repos)

c) even change architecture (on x86_64) if the same thing happens as explained in b)

A zypper up (= zypper update) won’t do this, as it will keep vendors.

The only unattended updates that are reasonably safe, are the ones from the official update-repo, and this can be configured with YaST (Online Update Configuration) or by using the update-applet.

Thanks Akoellh. I needed someone who told it again, but in different wordings :slight_smile: .