Cannot Clear Safari Cache

Philein
New Contributor III

Hi,
i'm trying to clear Safari cache on login with this script

#!/bin/bash

loggedInUser=`python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "
");'`

rm -R /Users/$loggedInUser/Library/Application Support/Google/Chrome
rm -R /Users/$loggedInUser/Library/Caches/com.apple.Safari

The Chrome part works fine, but on Safari i receive this error:
Script result: rm: /Users/myusername/Library/Caches/com.apple.safari: Operation not permitted
Error running script: return code was 1.

Could you please help me to solve that?

0 REPLIES 0