AutoPkg repo and logfile cleanup scripts for use with autopkg-conductor
2021-05-15 01:02:49 Author: derflounder.wordpress.com(查看原文) 阅读量:185 收藏

Home > AutoPkg, autopkg-conductor, macOS, Scripting > AutoPkg repo and logfile cleanup scripts for use with autopkg-conductor

As part of running autopkg-conductor over a long period of time, you may see a large percentage of disk space used on the Mac where you’re running AutoPkg and autopkg-conductor. This is because AutoPkg doesn’t remove older files from ~/Library/AutoPkg/Cache and autopkg-conductor does not remove older logfiles from ~/Library/Logs. To assist with this issue, I’ve written a couple of scripts. For more details, please see below the jump.

To assist with preserving available disk space on your AutoPkg host Mac, the following scripts are available:

  • 801.clean-autopkg-repo
  • 802.remove.autopkg.conductor.logs

Both scripts are designed to be installed into the following location:

/etc/periodic/daily

Installing them in that location will enable the periodic tool to run both scripts daily on your AutoPkg host Mac.

Permissions for both scripts should be set as follows:

root:wheel - rwxr-xr-x

The 801.clean-autopkg-repo script does the following task:

  • Determine which files in your ~/Library/AutoPkg/Cache are older than the number of days specified in the script (by default, 20 days)
  • Delete all files in ~/Library/AutoPkg/Cache which are older than the specified number of days

This script is available below and also from GitHub at the following location:

https://github.com/rtrouton/autopkg-conductor/blob/main/cleanup_scripts/801.clean-autopkg-repo

#!/bin/bash
# Remove AutoPkg-downloaded files older than a specified number of days
# Add username of the account used to run AutoPkg
autopkg_username="autopkg"
# Age of files to retain. For example, setting the following number
# will delete anything older than 20 days
#
# autopkg_cache_age="20"
autopkg_cache_age="20"
/usr/bin/find "/Users/$autopkg_username/Library/AutoPkg/Cache" -mindepth 1 -mtime +"$autopkg_cache_age" -delete

The 802.remove.autopkg.conductor.logs script is designed to do the following:

  • Determine which autopkg-conductor log files in the ~/Library/Logs directory are older than the number of days specified in the script (by default, 20 days)
  • Delete all relevant logfiles in the ~/Library/Logs directory which are older than the specified number of days.

This script is available from GitHub at the following location:

https://github.com/rtrouton/autopkg-conductor/blob/main/cleanup_scripts/802.remove.autopkg.conductor.logs

#!/bin/bash
# Remove autopkg-conductor logfiles older than a specified number of days
# Add username of the account used to run AutoPkg
autopkg_username="autopkg"
# Age of logfiles to retain. For example, setting the following number
# will delete anything older than 20 days
#
# autopkg_log_age="20"
autopkg_log_age="20"
/usr/bin/find "/Users/$autopkg_username/Library/Logs" -name "autopkg-run-for*" -mindepth 1 -mtime +"$autopkg_log_age" -delete

文章来源: https://derflounder.wordpress.com/2021/05/14/autopkg-repo-and-logfile-cleanup-scripts-for-use-with-autopkg-conductor/
如有侵权请联系:admin#unsafe.sh