Azure / Azure/WALinuxAgent

waagent downloads updates to /var/lib/waagent but doesn't remove the old .zip files

Open
#2,489 5 comments 0 reactions 1 assignee Claimed by @narrieta View on GitHub
V2
Dominant language
Python
Stars
581
Forks
397
Avg merge
2d 15h
Merged PRs (30d)
9

Description

Description: Any Linux OS running waagent for a few months will have at least a few .zip files at /var/lib/waagent that corresponds to older versions of the WALinuxAgent file that is downloaded every time Azure pushes a new update.

Over time these files start to pile up and add up to unnecessary space utilization on the root file syste or /var if LVM is in use.

The idea is to include a log rotation config file to automatically find and delete these files or even adding a cron job to this would be fine.

- Distro and Version: All
- WALinuxAgent version: All

It's easy to check this on any server that has been running waagent for more that a few months ( about 6-8 months ).

Just run:

`/usr/bin/find /var/lib/waagent -name "WALinuxAgent*.zip" -type f -exec ls -ltr {} \+`

An you will see all the old updates downloaded by the waagent

As an example, an easy way to fix this is by adding a log rotate config file with these commands

```
cat << EOF > /etc/logrotate.d/waagent.cleanup
/var/lib/waagent/*.zip {
# Ignore if there are no zip files at /var/lib/waagent/
missingok

# Don't send email
nomail

postrotate
# Remove any file that matches WALinuxAgent*.zip and its older than 60 days
/usr/bin/find /var/lib/waagent -name "WALinuxAgent*.zip" -type f -mtime +60 -exec rm {} \;
endscript
}
EOF
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.