Solved Check for new packages via cron?

TobiasW

New Member

Reaction score: 2
Messages: 11

Can you recommend a way to automatically check for new packages via cron?

As a first step I added a daily
pkg audit -q
but this only lists vulnerable packages.

pkg update does not what I want and pkg upgrade is one step too far.
Is there maybe something similar to freebsd-update cron for packages?
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 13,151
Messages: 39,766

How about pkg version -vRL=?
 

Mjölnir

Daemon

Reaction score: 1,519
Messages: 2,114

Like with many other tools, you can use the -n/--dry-run command line switch - s/t it's called uppercase -N. Check that you did not change the default REPO_AUTOUPDATE=true in /usr/local/etc/pkg.conf, else you have to issue pkg update before pkg upgrade -n
 
OP
TobiasW

TobiasW

New Member

Reaction score: 2
Messages: 11

Thank you for your help!

I investigated both options.

For my purpose
pkg version -vURL=
seems to fit, because it only generates output if new packages are available.

As I understand it -U does not update the local repo but I do not need it as I check against remote via -R.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 13,151
Messages: 39,766

As I understand it -U does not update the local repo but I do not need it as I check against remote via -R.
The remote catalog is cached locally. This is what pkg update does and what the -U option is referring to.
 
OP
TobiasW

TobiasW

New Member

Reaction score: 2
Messages: 11

Thank you once more!

So -U seems to be a bad idea (if pkg update is not run manually beforehand).

To suppress
~> sudo pkg version -vRL=
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.

I'll try following crontab entry
@daily root pkg update > /dev/null && pkg version -vURL=
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 13,151
Messages: 39,766

Why don't you just add a check script to the daily or weekly periodic(8)? There are a whole bunch of checks being done automatically. Just forward them to an admin's mailbox and check them regularly.
 
OP
TobiasW

TobiasW

New Member

Reaction score: 2
Messages: 11

Also the input about periodic(8) is appreciated.
However, I think in my case it helps to keep the overview by having one-liners in /etc/crontab.
At the moment I see no benefit from outsourcing it to an own script file.

My mentor came up with yet another approach in order to keep the output as silent as possible:
if ! pkg upgrade -n > /dev/null;then pkg upgrade -n;fi

By doing so we hope to avoid the listing of held-back packages.

Of course, only time will show what will work best but you have showed me the possible ways to go.
Thank you!
 
Last edited:
Top