Skip to content

Instantly share code, notes, and snippets.

@mrcomoraes
Last active May 10, 2024 12:07
Show Gist options
  • Save mrcomoraes/c83a2745ef8b73f9530f2ec0433772b7 to your computer and use it in GitHub Desktop.
Save mrcomoraes/c83a2745ef8b73f9530f2ec0433772b7 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, Debian by @necrifede, Arch Linux by @lucas-dclrcq and Manjaro with flatpak by @danie1k. Feel free to test/use in other distributions.
# Tested Teams via snap package.
# Tested Teams via flatpak package.
#
# How to use in terminal:
# ./clear_cache_MS_Teams.sh ( deb-stable | deb-insider | snap | flatpak )
# or
# bash clear_cache_MS_Teams.sh ( deb-stable | deb-insider | snap | flatpak )
# Variable process name is defined on case statement.
case $1 in
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
;;
flatpak)
export TEAMS_PROCESS=teams
cd "$HOME"/.var/app/com.microsoft.Teams/config/Microsoft/Microsoft\ Teams || exit 1
;;
*)
echo "Use $0 ( deb-stable | deb-insider | snap | flatpak ) 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
killall ${TEAMS_PROCESS_NAME}
# After this, MS Teams will open again.
else
echo "Microsoft Teams is not running."
exit
fi
@mrcomoraes
Copy link
Author

@MarekGajdosik and @maksimdzmitryew this "Teams for Linux" snap is a unofficial project that using Electron for deliver MS Teams. I beleive Microsoft removed Teams snap packages. I guess do a upgrade in snap option to support unofficial version.

@SirStifler
Copy link

Here is my first time on GitHub.
However, here is my contribution to this topic.
I have Ubuntu as my SO, and my teams-for-Linux is a fork on the Snap.

I changed lines 24, 25, and 26 to:

snap)
export TEAMS_PROCESS_NAME=teams-for-linux
cd /snap/teams-for-linux || exit 1

Why?
run ps to find your teams-for-linux process and you will see that:

$ ps -ef |grep teams-for-linux
me 324126 323853 0 12:32 ? 00:00:00 /snap/teams-for-linux/523/teams-for-linux --type=utility --utility-sub

So my teams-for-linux is on directory /snap/teams-for-linux
and the TEAMS_PROCESS_NAME is teams-for-linux and not just teams

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment