Category filter

Script to clear cache on macOS devices

Jump To

Periodically clearing the cached data and log files on your Mac will help protect your data and free up additional storage space. Moreover, deleting the app cache can also help fix issues with certain apps and ensure the smooth operation of your devices. Run this bash script using Hexnode’s Execute Custom Script action to delete all the cached data stored on your macOS devices.

Scripting Language – Bash

File extension – .sh

Disclaimer:


The Sample Scripts provided below are adapted from third-party Open-Source sites.

Clear all cache

This bash script clears:

  • System cache
  • Browser cache
  • User cache
  • Download history
  • Terminal history
Notes:

  • It is recommended to manually validate the script execution on a system before executing the action in bulk.
  • Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.

  • Sample Script Repository