Chrome - Clear History, Cache, Cookies on Restart

ngedemer
New Contributor

Trying to have all users' computers restart every morning;

I have a script that kills all processes and restarts after 1minute. I need a script to also remove the cookies, history, and cache of Chrome on said restart so they essentially start "fresh" each day without losing their extensions.

Tried this but it's not working:

!/bin/sh

Remove Google Chrome Browser Cache Cookies and Extension Logins

sudo rm -Rf ~/Library/Caches/Google/Chrome/Default/Cache/
sudo rm -Rf ~/Library/Application Support/Google/Chrome/Default/Cookies/
sudo rm -Rf ~/Library/Application Support/Google/Chrome/Default/Cookies-journal/
sudo rm -Rf ~/Library/Application Support/Google/Chrome/Default/Extension/
sudo rm -Rf ~/Library/Application Support/Google/Chrome/Default/Extension-journal/
sudo rm -Rf ~/Library/Application Support/Google/Chrome/Default/History/
sudo rm -Rf ~/Library/Application Support/Google/Chrome/Default/History-journal/

Thanks

9 REPLIES 9

ThierryD
New Contributor III

Did you find something already ?

Noch
New Contributor

Looking for this exact thing as well.

mhegge
Contributor III

Me too, as well as Safari data, but I know there are SIP issues relate to that.

willjdaniel
New Contributor II

This is what I use for Cookies, but could be easily modified to include everything else you need.

#!/bin/bash
## System Variables
USERNAME=`stat -f%Su /dev/console`
COOKIEPATH="/Users/$USERNAME/Library/Application Support/Google/Chrome"

find "$COOKIEPATH" -name Cookies -delete

pkill Google Chrome

ssagola
New Contributor III

I want to do the exact opposite. I want to keep the students from deleting their browsing history. Is that doable 🙂 is there a script for that?

OPLH
New Contributor II

Check out Chrome Management, there's built-in functionality with JAMF Pro now. which makes enrolling browsers very easy, one of the policies you can set once enrolled is not being able to delete history.

https://www.jamf.com/blog/admin-essentials-simplifying-chrome-deployments-on-macos/ 

https://support.google.com/chrome/a/answer/9923111?hl=en

Have just rolled this out so feel free to shoot through a DM if you have any questions.

ssagola
New Contributor III

For iPads? IOS

OPLH
New Contributor II

I haven't tried it on iOS but from what i've seen its only for MacOS, Windows, Linux and ChromOS

OPLH
New Contributor II

I've just checked it out and looks like there is the ability for iOS devices. unsure on the enrolment process for ipads though.Screen Shot 2021-11-04 at 9.23.11 am.png