Last active
March 1, 2024 07:54
-
-
Save edenwaith/5eb512d82182b71665741a16dcd6c1b7 to your computer and use it in GitHub Desktop.
Clear the cached calendars for macOS Calendar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Author: Chad Armstrong | |
# Date: 29 August 2018 | |
# Description: Clear the cached calendars for macOS Calendar | |
# References: | |
# https://michaelkummer.com/technology/fix-calendar-cant-save-event-x-exchange/ | |
# https://wilkinsit.ca/mac-osx/clear-calendar-cache-mac-os/ | |
# https://stackoverflow.com/a/3510850/955122 | |
# https://alvinalexander.com/blog/post/mac-os-x/applescript-delay-command | |
# Quit the Calendar and Itsycal apps | |
osascript -e "tell application \"Calendar\"" -e "quit" -e "end tell" | |
osascript -e "tell application \"Itsycal\"" -e "quit" -e "end tell" | |
# Delete all of the Calendar Cache files | |
rm -rfv ~/Library/Calendars/Calendar\ Cache* | |
# Kill all processes with the word Calendar in the name (e.g. Calendar, CalendarAgent) | |
kill $(ps auxc | grep Calendar | awk '{print $2}') | |
# Restart the Calendar app | |
osascript -e "tell application \"Calendar\"" -e "activate" -e "end tell" | |
# Reopen Itsycal after a delay to give Calendar some time to refresh itself | |
osascript -e "tell application \"Itsycal\"" -e "delay 30" -e "activate" -e "end tell" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment