# pkg reports 'advisory lock' error



## unitrunker (Aug 9, 2019)

This was a small surprise the other evening. Typing 'pkg install some-thing' reported an error that an 'advisory lock' was held by another process. Checked the process list and found that cron was running a nightly housekeeping script on pkg. After a few minutes had passed, the cron job finished and I was able to resume installing / upgrading packages.

You can see the housekeeping scripts here:

/usr/local/etc/periodic/daily/411.pkg-backup
/usr/local/etc/periodic/daily/490.status-pkg-changes

Good to know the base system does this for you!


----------



## SirDice (Aug 9, 2019)

The daily security emails provide some useful package information. It runs at 3:01am. 

For example:

```
Checking for packages with security vulnerabilities:
Fetching vuln.xml.bz2: .......... done
python36-3.6.8_2 is vulnerable:
python 3.6 -- multiple vulnerabilities
CVE: CVE-2019-9740
CVE: CVE-2019-9948
WWW: https://vuxml.FreeBSD.org/freebsd/18ed9650-a1d6-11e9-9b17-fcaa147e860e.html

1 problem(s) in 1 installed package(s) found.

Checking for packages with mismatched checksums:

-- End of security output --
```
It tells me I need to update my Python.


----------



## unitrunker (Aug 10, 2019)

This was on a laptop that doesn't normally run at 3am.


----------



## sidetone (Feb 6, 2020)

My periodic script was running `pkg check`, from /usr/local/etc/periodic/security/. I did `doas ps ax | grep pkg`.

I was compiling from ports using portmaster starting before 3am, and there was an error that occurred. When I tried to restart compiling, there was lock. Then, I looked at the time, past 3 am.

I thought the periodic script interrupted my portbuild at first, but the error was about a pkg conflict. And the lock from that build perhaps would prevent the periodic script from running, unless portmaster didn't hold that lock between building different ports.


----------



## Oclair (Nov 17, 2022)

sidetone said:


> My periodic script was running `pkg check`, from /usr/local/etc/periodic/security/. I did `doas ps ax | grep pkg`.
> 
> I was compiling from ports using portmaster starting before 3am, and there was an error that occurred. When I tried to restart compiling, there was lock. Then, I looked at the time, past 3 am.
> 
> I thought the periodic script interrupted my portbuild at first, but the error was about a pkg conflict. And the lock from that build perhaps would prevent the periodic script from running, unless portmaster didn't hold that lock between building different ports.


I suspect in this situation portmaster ends in error and does not return a locked database error and instead reports something regarding the port is already installed...


----------



## zirias@ (Nov 17, 2022)

unitrunker said:


> This was on a laptop that doesn't normally run at 3am.


There's sysutils/anacron if you want to enable regular housekeeping on such systems as well.


----------

