Skip to content

Instantly share code, notes, and snippets.

@kuirolo
Forked from mrcomoraes/clear_cache_MS_Teams.sh
Last active April 27, 2021 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kuirolo/5e1f80dfb6f4626b1250e618af83b0e3 to your computer and use it in GitHub Desktop.
Save kuirolo/5e1f80dfb6f4626b1250e618af83b0e3 to your computer and use it in GitHub Desktop.
Clear cache Microsoft Teams on Linux
#!/bin/bash
# This script cleans all cache for Microsoft Teams on Linux
# Tested on Ubuntu-like and Debian by @necrifede. Feel free to test/use in other distributions.
# Tested with Teams via snap package.
#
# How to use in terminal:
# ./clear_cache_MS_Teams.sh ( deb-stable | deb-insider | snap )
# or
# bash clear_cache_MS_Teams.sh ( deb-stable | deb-insider | snap )
# Variable process name is defined on case statement.
case $1 in
flatpak)
export TEAMS_PROCESS_NAME=teams
cd "$HOME"/.var/app/com.microsoft.Teams/config/Microsoft/Microsoft\ Teams || exit 1
;;
deb-stable)
export TEAMS_PROCESS_NAME=teams
cd "$HOME"/.config/Microsoft/Microsoft\ Teams || exit 1
;;
deb-insider)
export TEAMS_PROCESS_NAME=teams-insiders
cd "$HOME"/.config/Microsoft/Microsoft\ Teams\ -\ Insiders || exit 1
;;
snap)
export TEAMS_PROCESS_NAME=teams
cd "$HOME"/snap/teams/current/.config/Microsoft/Microsoft\ Teams || exit 1
;;
*)
echo "Use $0 ( deb-stable | deb-insider | snap) as parameter."
exit 1
;;
esac
# Test if Microsoft Teams is running
if [ "$(pgrep ${TEAMS_PROCESS_NAME} | wc -l)" -gt 1 ]
then
rm -rf Application\ Cache/Cache/*
rm -rf blob_storage/*
rm -rf Cache/* # Main cache
rm -rf Code\ Cache/js/*
rm -rf databases/*
rm -rf GPUCache/*
rm -rf IndexedDB/*
rm -rf Local\ Storage/*
#rm -rf backgrounds/* # Background function presents on Teams for Windows only.
find ./ -maxdepth 1 -type f -name "*log*" -exec rm {} \;
sleep 5
# SIGTERM will leave teams unresponsive
killall -s SIGKILL ${TEAMS_PROCESS_NAME}
# After this, MS Teams will open again.
else
echo "Microsoft Teams is not running."
exit
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment