Prunes inactive local user accounts on shared Macs.
--secure: immediately secure-deletes inactive users.--soft(default): drops a marker file (/Users/<user>/.pruneusers) and defers deletion until grace period expires.
When a user reaches the inactivity threshold in soft mode:
- Script writes
/Users/<user>/.pruneusers - Marker stores
delete_onand metadata - Account/home are left in place during grace period
On later runs:
- If user activity resumes (logged in now or inactivity falls below threshold), marker is removed.
- If
delete_onis reached and user remains inactive, account/home are deleted.
- Daily logs:
/var/log/PruneUsers/PruneUsers-YYYY-MM-DD.log - launchd stdout/stderr:
/var/log/PruneUsers-launchd.log - Old daily logs are pruned automatically by retention policy.
PruneUsers.zsh [options] [days_inactive]
Options:
-h --helpshow help-v --verboseverbose logging-n --dry-runsimulation mode--securesecure delete mode--softsoft delete mode--debugdebug logging
Examples:
./PruneUsers.zsh --secure 14./PruneUsers.zsh --soft --dry-run 45
Settings path:
/Library/Managed Preferences/com.maxhewett.pruneusers.plist
Supported keys:
DeletionMethod(softorsecure)InactivityDays(integer)SoftDeleteGraceDays(integer)LogRetentionDays(integer,0disables pruning)
Priority order:
- Command-line arguments
- Managed preferences
- Script defaults (
soft, inactivity30, grace14, log retention30)
- Example managed preferences payload:
com.maxhewett.pruneusers.managed-preferences.example.plist - Jamf Custom Settings schema:
jamf/com.maxhewett.pruneusers.schema.json - Preference domain:
com.maxhewett.pruneusers
Quick setup:
- Upload the schema file to a Jamf Application & Custom Settings payload.
- Use preference domain
com.maxhewett.pruneusers. - Configure
DeletionMethod,InactivityDays,SoftDeleteGraceDays, andLogRetentionDays. - Deploy this profile to target Macs and run the LaunchDaemon on schedule.
Use a root LaunchDaemon (not a user LaunchAgent).
- Script:
/Library/Application Support/PruneUsers/PruneUsers.zsh - Daemon:
/Library/LaunchDaemons/com.maxhewett.UserPruner.plist - Load:
launchctl bootstrap system /Library/LaunchDaemons/com.maxhewett.UserPruner.plist
Keep timing in the daemon and behavior in managed preferences.