Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Remove Safari history files on logout via shell script' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Remove Safari history files on logout via shell script
Authored by: RedFred on Jul 06, '09 04:01:05PM
Logout hooks are run as the root user SO ALWAYS USE CAUTION WHEN DOING THIS!. If you want to know what the short user name of the user logging out is, it is stored in the $1 shell variable, so the correct generalized scripts should be:

#!/bin/bash

# Clear Safari History (except for bookmarks).
/bin/rm -f /Users/$1/Library/Safari/Downloads.plist /Users/$1/Library/Safari/History.plist 
/bin/rm -f /Users/$1/Library/Safari/HistoryIndex.sk /Users/$1/Library/Safari/TopSites.plist 
/bin/rm -f /Users/$1/Library/Safari/WebpageIcons.db /Users/$1/Library/Safari/LastSession.plist

# Add any additional clean-up here.
Also you should use the full path to the rm command so you know you are getting the correct version. Also you may want to add in the
/bin/rm -f /Users/$1/Library/Caches/com.apple.Safari/Cache.db
/bin/rm -rf /Users/$1/Library/Caches/com.apple.Safari/Webpage Previews
For extra credit, you can set up a user agent to clean up Safari everytime it runs, thats what I do.

[ Reply to This | # ]