Unattended Upgrade End Script
I have the need of notifying my fleet management system every time unattended-upgrades
run, and sending some information on the packages updated.
Is there any way to detect the end of unattended upgrade and launch a script when the process ends?
So far I have a script that runs daily with this approach:
- I check for
/var/log/unattended-upgrades/unattended-upgrades.log
existence. - If it exists, parse info from it and report back to the server the update status.
- Delete the file
Unattended-upgrades run weekly, but the log file is still created daily. Having a hook on unattended-upgrades run would be very handy in my use case, to avoid false reporting.
Use a systemd path job to listen for changes to the file /var/lib/apt/periodic/unattended-upgrades-stamp
That file gets touched when unattended upgrades completes operation. There is no data in the file; the touch merely updates the 'modified' timestamp in the filesystem.