Created
June 27, 2019 16:07
-
-
Save talkingmoose/c1fd6e7fcec3000c9b2e590ae86c4de6 to your computer and use it in GitHub Desktop.
Useful for killing all running applications that may prevent a restart for an upgrade. Killing apps does not allow for saving work. Use only as a last resort.
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/bash | |
# there's probably a better way to use lsappinfo to get the list of apps, but it's not well documented | |
appsList=$( /usr/bin/lsappinfo list | /usr/bin/grep -B 4 Foreground | /usr/bin/awk -F '\\) "|" ASN' 'NF > 1 { print $2 }' ) | |
# kill each app by name except Finder | |
while IFS= read anApp | |
do | |
if [ "$anApp" != "Finder" ]; then | |
/usr/bin/pkill "$anApp" | |
echo "Killing app '$anApp'" | |
fi | |
done <<< "$appsList" | |
# wait a few second and kill Microsoft Error Reporting tool if it opens by killing a Microsoft app | |
sleep 3 | |
/usr/bin/pkill "Microsoft Error Reporting" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment